Entity Framework 4.1 Code First EDMX issue

眉间皱痕 提交于 2019-12-11 03:09:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!