What is Entity Framework
Entity framework is an ORM framework.
ORM: Object Relation Mapping
Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.
- Create a new Asp.NET Empty Web Site.
Click on File, WebSite, then ASP.NET Empty Web Site.
![EMPTY]()
- Install EntityFramework through NuGet.
![NUGET]()
![NUGET]()
![NUGET]()
![NUGET]()
- Table Structure
- USE [MemberCDAC]
- GO
- /****** Object: Table [dbo].[tblFriends] Script Date: 01/31/2016 19:34:14 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- SET ANSI_PADDING ON
- GO
- CREATE TABLE [dbo].[tblFriends](
- [FriendID] [int] IDENTITY(1,1) NOT NULL,
- [FriendName] [varchar](50) NULL,
- [Place] [varchar](25) NULL,
- [Mobile] [varchar](15) NULL,
- [EmailAddress] [varchar](150) NULL
- ) ON [PRIMARY]
-
- GO
- SET ANSI_PADDING OFF
![DBO]()
- Now, add the Entity Data Model,
![MODEL]()
- Select Generate from database.
![DATABASE]()
- Select connection,
![connection]()
- Select table,
![table]()
- After that click on Finish button,
![button]()
- Right click on Project. Select Add, then Add New ITtem,
![ADD NEW ITEM]()
![ADD NEW ITEM]()
- Drag and drop GridView control,
![GridView]()
- Select GridView, click on SMART TAG,
![SMART TAG]()
- Drag and drop EntityDataSource control,
![EntityDataSource control]()
- Select Connection,
![Connection]()
- Select configure data section.
![configure]()
- Select EntityDataSource for GridView.
![Select EntityDataSource]()
- Press F5 to execute.
![EntityDataSource]()
Refrences:
- https://entityframework.codeplex.com/