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.
- Install EntityFramework through 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
- Now, add the Entity Data Model,
- Select Generate from database.
- Select connection,
- Select table,
- After that click on Finish button,
- Right click on Project. Select Add, then Add New ITtem,
- Drag and drop GridView control,
- Select GridView, click on SMART TAG,
- Drag and drop EntityDataSource control,
- Select Connection,
- Select configure data section.
- Select EntityDataSource for GridView.
- Press F5 to execute.
Refrences:
- https://entityframework.codeplex.com/