Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Entity Framework Tutorial (Update)
Entity Framework Tutorial (Update)

Entity Framework Tutorial (Update): A comprehensive guide to the Entity Framework with insight into its latest features and optimizations for responsive data access in your projects , Second Edition

Arrow left icon
Profile Icon Joydip Kanjilal
Arrow right icon
₱2500.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (4 Ratings)
Paperback Aug 2015 274 pages 2nd Edition
eBook
₱1399.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
Arrow left icon
Profile Icon Joydip Kanjilal
Arrow right icon
₱2500.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (4 Ratings)
Paperback Aug 2015 274 pages 2nd Edition
eBook
₱1399.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
eBook
₱1399.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Entity Framework Tutorial (Update)

Chapter 2. Getting Started

In the previous chapter, we took a look at Entity Framework, including its architecture and its features. We also had a look at the new and enhanced features in Entity Framework 7. Note that Entity Framework 6.0 ships with Visual Studio 2013, but you can also install it via NuGet if needed. Also, Entity Framework 7 is yet to be released.

In this chapter, we will design our Security database, create an Entity Data Model (EDM) on top of it, and then use the EntityDataSource control to bind data exposed by the EDM to a GridView control.

The DataSource controls are those that are used to connect to a data source and then retrieve data from those data sources. If you use DataSource controls, the need of writing tedious code to perform Create, Read, Update, Delete (CRUD) operations on data-based controls is eliminated. The EntityDataSource control is a DataSource control that can connect to the data exposed by the EDM to perform CRUD operations.

In this chapter...

Designing the UserAuthentication database

Before we begin implementing a simple application that shows how data retrieved from the EDM can be consumed, let's take a quick look at the EDM again:

Designing the UserAuthentication database

As you can see in this diagram, our application needs to interact with the CSDL layer. The SSDL layer will connect to the database (the Security database in our example), and the mapping layer will map these two layers so that they can communicate.

The Security database comprises of a list of the following tables:

  • Users: This table contains the user details.
  • UsersAuthentication: This table contains the user authentication details.
  • UserAuthenticationTypes: This table contains user authentication type data. User authentication type can be Windows, Forms, Passport, and Anonymous.
  • UsersLoginHistory: This table contains data related to user login history; that is, the user login history data of the user.
  • UserRoles: This table contains the user role details.
  • Roles: This table contains the role details.
  • Controls...

Creating the EDM

Now that the Security database is ready, we will explore how we can create an EDM on top of the Security database.

Note

Note that, before Entity Framework 7, there were two storage models—the EDMX file format based on XML schema or code. With Entity Framework 7, the EDMX file format will be dropped—we will have only the code-based format. Interestingly, this approach is also termed the "code-first only" approach.

You can create the Entity Data Model in one of two ways:

  • Use the ADO.NET Entity Data Model Designer
  • Use the command-line Entity Data Model Designer called EdmGen.exe

The first approach is preferred to the second. However, as we move through the chapters of the book, we will explore how we can follow the code-first approach to implement the model for our application that uses Entity Framework.

We will first take a look at how we can design an EDM using the ADO.NET Entity Data Model Designer.

Creating the Entity Data Model using the ADO.NET Entity...

The DataSource controls

The DataSource controls are those that can be bound to data from external data sources. These data sources may include databases, XML files, or even flat files. ASP.NET 2.0 introduced some DataSource controls with a powerful data binding technique, so the need for writing lengthy code for binding data-to-data controls has been eliminated.

Note

In ASP.NET, the term data binding implies binding the controls to data retrieved from a data source and providing read or write connectivity between these controls and the data that they are bound to.

A DataSource control acts like a layer in between your data source and the data bound control. Data bound controls can be any control that actually interacts with the end user while consuming the data services provided by the DataSource control to which it is bound. It defines certain methods and properties that perform data-specific operations like insert, delete, update, and select over the data exposed by the DataSource control...

Implementing our first application using the Entity Framework

In this section, we will learn how to use the EDM and the EntityDataSource control to implement our first program using the Entity Framework. We will use a GridView control to display bound data.

Let's first have the environment ready. I will run you through the steps to download and install Entity Framework 6 now.

In the Solution Explorer, right-click on the project and select EntityFramework from the list of NuGet packages, as shown in the following screenshot:

Implementing our first application using the Entity Framework

Click on Install to start downloading and installing Entity Framework 6:

Implementing our first application using the Entity Framework

Once Entity Framework 6 has been downloaded, click on Accept to start the installation. After Entity Framework 6 has been successfully installed and the necessary changes applied to your project, you are ready to start writing your first application that makes use of this framework.

Implementing our first application using the Entity Framework

Refer to the solution we created earlier using the Entity Data Model Designer. Now follow these steps:

  1. Drag and drop...

Summary

In this chapter, we discussed how we can get started with Entity Framework. You learned how to create an EDM and use it along with the EntityDataSource control, to bind data to a GridView data control. In this chapter, we created the UserAuthentication database and an EDM that exposed this database. We also explored the EntityDataSource control and used it to bind data in our first application that leverages Entity Framework 6.

In the next chapter, we will continue to explore the EDM including each of its sections and will learn how they are related to each other.

Left arrow icon Right arrow icon

Key benefits

  • Create Entity data models from your database and use them in your applications
  • Learn about the Entity Client data provider and write statements in Entity SQL to perform CRUD operations
  • Explore ADO.NET Data Services and how they work with the Entity Framework

Description

The ADO.NET Entity Framework from Microsoft is a new ADO.NET development framework that provides a level of abstraction for data access strategies and solves the impedance mismatch issues that exist between different data models This book explores Microsoft’s Entity Framework and explains how it can used to build enterprise level applications. It will also teach you how you can work with RESTful Services and Google’s Protocol Buffers with Entity Framework and WCF. You will explore how to use Entity Framework with ASP.NET Web API and also how to consume the data exposed by Entity Framework from client applications of varying types, i.e., ASP.NET MVC, WPF and Silverlight. You will familiarize yourself with the new features and improvements introduced in Entity Framework including enhanced POCO support, template-based code generation, tooling consolidation and connection resiliency. By the end of the book, you will be able to successfully extend the new functionalities of Entity framework into your project.

Who is this book for?

If you are a C# developer who wants to learn a new way of querying data and utilizing it in applications efficiently for data binding or other operations, then this book is for you. Basic knowledge of ADO.NET is assumed.

What you will learn

  • Explore the features of the ADO.NET Entity Framework
  • Understand the concepts of entities and their relationships
  • Create an Entity Data Model using the ADO.NET Entity Data Model Designer and the EdmGen tool
  • Extend existing Entity Types to create your own Entity Types
  • Write programs against the Entity Data Model to perform CRUD operations
  • Discover ADO.NET Data Services and learn how they can be used with the Entity Framework
  • Familiarize yourself with WCF Data Services (formerly ADO.NET Data Services)
  • Apply Code First, Model First and Database First approaches
Estimated delivery fee Deliver to Philippines

Standard delivery 10 - 13 business days

₱492.95

Premium delivery 5 - 8 business days

₱2548.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 24, 2015
Length: 274 pages
Edition : 2nd
Language : English
ISBN-13 : 9781783550012
Vendor :
Microsoft
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Philippines

Standard delivery 10 - 13 business days

₱492.95

Premium delivery 5 - 8 business days

₱2548.95
(Includes tracking information)

Product Details

Publication date : Aug 24, 2015
Length: 274 pages
Edition : 2nd
Language : English
ISBN-13 : 9781783550012
Vendor :
Microsoft
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 5,307.98
Entity Framework Tutorial (Update)
₱2500.99
Entity Framework Core Cookbook
₱2806.99
Total 5,307.98 Stars icon
Banner background image

Table of Contents

10 Chapters
1. Introducing the ADO.NET Entity Framework Chevron down icon Chevron up icon
2. Getting Started Chevron down icon Chevron up icon
3. Entities, Relationships, and the Entity Data Model Chevron down icon Chevron up icon
4. Working with Stored Procedures in the Entity Data Model Chevron down icon Chevron up icon
5. Working with Entity Client and Entity SQL Chevron down icon Chevron up icon
6. Working with LINQ to Entities Chevron down icon Chevron up icon
7. Working with the Object Services Layer Chevron down icon Chevron up icon
8. Working with WCF Data Services Chevron down icon Chevron up icon
A. Advanced Concepts Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
(4 Ratings)
5 star 25%
4 star 0%
3 star 0%
2 star 0%
1 star 75%
Jim Feb 01, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nice one!
Amazon Verified review Amazon
Amazon Customer Jan 28, 2016
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
DO NOT WASTE YOUR MONEY!! Very glad I bought the least expensive Kindle edition. The book is poorly written, the grammar is severely lacking, the editor/reviewer should be fired for incompetence, and the samples in the companion download bear zero resemblance to the text of the book. One example (of MANY): Chapter 2 introduces EntityDataSource controls. It says to use Visual Studio 2013, SQL Server 2014, and Entity Framework 6 as the necessary versions for following the text. The text then says to create a simple ASP.NET web project and drag the EntityDataSource control from the toolbox to the web form. However, the EntityDataSource control in the toolbox is:1. From EF version 52. NOT compatible with EF 63. NOT upgradable to the EF 6 version of the control (per Microsoft)This renders the rest of the section in the text for configuring the control completely irrelevant for EF 6. This is one example of many that I have had to work around or try to figure out just in the first few chapters - worthless book.
Amazon Verified review Amazon
Amazon Customer Mar 07, 2016
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
This book is not a real book but just an early draft of a book. It's full of typos, copy-paste errors, same sentences placed multiple times on adjacent pages, blah-blah with no details etcIt's amazing how poor the quality of this 'book' is.
Amazon Verified review Amazon
Andrew Stegmaier Apr 30, 2016
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
It feels like this book was written by a machine AI that copied and pasted marketing slogans, random snippets from stackoverflow, and meaningless powerpoint diagrams. If you're like me, you were hoping to get a tutorial in entity framework that would start from basic concepts and and build from there, you will be bewildered by the constant use of unexplained terminology and the redundant, disorganized style. (For a random example, consider p. 21 "features at a glance"--it's a list of high-level marketing bullets about all the features of Entity Framework, some of which have been discussed previously, other's of which are completely opaque. What is a summary like this doing in the _middle_ of a chapter, surrounded by highly detailed explanations of specific concepts???). Don't waste your money or time on this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela