Note: This is not about the difference between Database first, Model first, and Code first.
Microsoft has a number of tools to simplify using DbContext. Unfortunately, there seems to be almost no description and also no documentation on what they are, much less what they do.
What is the difference between:
I don’t usually answer my own questions, but here is what I figured out:
The difference between the
ADO.NET C# DbContext Generatorand theADO.NET C# POCO Entity Generatoris that the former creates a context based on theDbContextand the latter creates them based on theObjectContext.Basically, these are used in the
Model FirstandDatabase Firstapproaches. The difference betweenModel FirstandDatabase Firstis that inDatabase First, you define your data model in the database, then reverse engineer the model (ie. create an .edmx file) from the database. While withModel First, you create your model in the designer (again, the .edmx file) or by hand, then generate the database from that model.In both cases, you then generate POCO classes and either a
DbContextorObjectContextfrom the .edmx file.The
Entity Framework Power Tools CTP1reverse engineers aCode Firstmodel from the database, including POCO class, theDbContext(don’t think it offersObjectContextgeneration) and the mappings (via theOnModelCreatingmethod).So what this boils down to is that in
Database FirstandModel First, the “model” is defined by the xml .edmx file (or in some cases, several files). While inCode First, the model is defined using fluent code mappings inOnModelCreating.When using the Power Tools to reverse engineer the database, it doesn’t create an .edmx file, instead creating the mappings in code. Thus, skipping the xml middle man.