From my understanding. In the Database First pattern of EF. We can generate code for the entity class by some Template. such as T4 Template, DbContext Generator Template etc. But I also can find the same entity class definition in the Designer.cs file . Here is my questions.
-
What is the purpose of the EF Code generator? The Designer.cs file has all well defined entity class. Is it necessary to generate entity class code one by one?
-
How many Templates are there in the EF? What is the difference between them?
The EF power tools allow you to generate code first entities for an existing database.
The reason you would use this as opposed to a database first (EDMX) approach is that going forward from now you would like to use code-first to manage database updates. This means you can use EF migrations as opposed to making changes directly to the database and then updating your EDMX.
In terms of other apps which generate code files from a database all EF methods will eventually generate code (not just code first) however only code first gives you control over the generated classes (although you can use partial classes with EDMX generation). Model and Database first methods rely on regenerating classes as the model/database changes.
As far as I know the EF power tools are the best way (and the only microsoft way) to produce a code-first model from an existing database