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
Mex$561.99 Mex$803.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (4 Ratings)
eBook Aug 2015 274 pages 2nd Edition
eBook
Mex$561.99 Mex$803.99
Paperback
Mex$1004.99
Subscription
Free Trial
Arrow left icon
Profile Icon Joydip Kanjilal
Arrow right icon
Mex$561.99 Mex$803.99
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (4 Ratings)
eBook Aug 2015 274 pages 2nd Edition
eBook
Mex$561.99 Mex$803.99
Paperback
Mex$1004.99
Subscription
Free Trial
eBook
Mex$561.99 Mex$803.99
Paperback
Mex$1004.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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

Billing Address

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

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 : 9781783550029
Vendor :
Microsoft
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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

Billing Address

Product Details

Publication date : Aug 24, 2015
Length: 274 pages
Edition : 2nd
Language : English
ISBN-13 : 9781783550029
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 Mex$85 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 Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 2,133.98
Entity Framework Tutorial (Update)
Mex$1004.99
Entity Framework Core Cookbook
Mex$1128.99
Total Mex$ 2,133.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.