Adding ADO.NET Entity Framework 5 support in asp.net
Step 1) Click Add new item-> Select ADO.NET Entity Data Model
Select ADO.NET Entity Framework Data Model Template |
Step 2) Select "Generate From Database" (Because Model is from Existing Database).
Select Generate From Database |
Step 3) Choose SQL Server Data Provider
Select SQL Server DataSource |
Step 4) Provide SQL Server Instance and Database Name and Connection Information |
Provide SQL Server Instance and Database |
Step 5) ADO.NET Entity Framework Connection String is Stored in the App.config/Web.config
Entity Framework Connection String stored in app/web.config |
Step 6) Select Tables you want
Select Tables from AdventureWorks |
Step 7) Generates Model1.edmx file as shown below.
Step 8) Model1.edmx
It has 4 files
- Model1.Context.tt
Model1.Designer.csModel1.edmx.diagramModel1.ttModel1.Context.tt has has DBContext Derived Class AdventureWorks2012Entities Specified in Step 5Model1.tt has Entities Related to Selected Tables.DBContext and Table Related Entities by default added to Same namespace.
Note: How to Access/Consume Entity Framework in C#,ASP.NET,Silverlight,WPF,Windows Form, Pls see other articles in this Website.
No comments:
Post a Comment