Why use EF 5.X DbContext Generator when Edmx does the same job?

c# entity-framework

Accepted Answer

In addition to constructing the EDMX for you when you add the new "ADO.NET Entity Data Model," it also builds the DbContext, which is "AdventureWorks DataEntities" for you.

The "EF 5.X DBcontext Generator" is already present in your project, therefore you don't need to add it. If you unfold your.edmx file in Visual Studio by clicking the arrow to the left of it, you will find many files. There will be two that end in ".tt." These are T4 templates that, when the EDMX is changed, automatically generate the model entities and the DbContext.

I hope this makes the principles clear. To personally address your inquiries:

You just need step 1, and your DbContext is AdventureWorks DataEntities. The "AdventureWorks DataEntities.cs" file contains a declaration that this class derives from DbContext.

Inquiry 2: You should ask a different question on how to integrate WPF with Entity Framework because this one is different. There are several internet resources that explain this, so I'd advise doing a search before you do this. Consider the following MSDN article: http://msdn.microsoft.com/en-us/data/jj574514.aspx

16
11/8/2013 3:02:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow