问题
The way I handle large projects using EF CF is by doing the following:
- Create a data model (EDMX)
- Disable the Model-First code generation feature for that model by clearing the Custom Tool property
- Use Entity Framework POCO Generator extension to add the relevant template (t4) files to the project
- Customize the template files to follow certain coding conventions we follow
This all looks good in concept but when we run the project, EF seems to think we are using the Model-First approach. This is not the case since we do not want the EDMX model mapped to any database. We expect the database to be created at runtime if the model has changed.
So how can we remove database mapping expectations of the EDMX?
回答1:
By not using EDMX. EDMX is the mapping. Once you use EDMX you are using either Model-first or Database-first. Code first means no EDMX and no code generators. The code in the approach name means that you are supposed to write that code. The only way to get entities and mapping generated in code first is when you have an existing database and you use EF Power Tools but if you don't have the database you don't have any such support.
来源:https://stackoverflow.com/questions/10385432/entity-framework-4-1-code-first-edmx-issue