Fetch Data Through Entity Framework

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.

  1. Create a new Asp.NET Empty Web Site.
    Click on File, WebSite, then ASP.NET Empty Web Site.

    EMPTY

  2. Install EntityFramework through NuGet.

    NUGET

    NUGET

    NUGET

    NUGET

  3. Table Structure
    1. USE [MemberCDAC]    
    2. GO    
    3. /****** Object: Table [dbo].[tblFriends] Script Date: 01/31/2016 19:34:14 ******/    
    4. SET ANSI_NULLS ON    
    5. GO    
    6. SET QUOTED_IDENTIFIER ON    
    7. GO    
    8. SET ANSI_PADDING ON    
    9. GO    
    10. CREATE TABLE [dbo].[tblFriends](    
    11. [FriendID] [int] IDENTITY(1,1) NOT NULL,    
    12. [FriendName] [varchar](50) NULL,    
    13. [Place] [varchar](25) NULL,    
    14. [Mobile] [varchar](15) NULL,    
    15. [EmailAddress] [varchar](150) NULL    
    16. ON [PRIMARY]    
    17.     
    18. GO    
    19. SET ANSI_PADDING OFF    
    DBO

  4. Now, add the Entity Data Model,

    MODEL

  5. Select Generate from database.

    DATABASE

  6. Select connection,

    connection

  7. Select table,

    table

  8. After that click on Finish button,

    button

  9. Right click on Project. Select Add, then Add New ITtem,

    ADD NEW ITEM

    ADD NEW ITEM

  10. Drag and drop GridView control,

    GridView

  11. Select GridView, click on SMART TAG,

    SMART TAG

  12. Drag and drop EntityDataSource control,

    EntityDataSource control

  13. Select Connection,

    Connection

  14. Select configure data section.

    configure

  15. Select EntityDataSource for GridView.

    Select EntityDataSource

  16. Press F5 to execute.

    EntityDataSource
Refrences:
  •  https://entityframework.codeplex.com/


Similar Articles