实体框架4.1 code首先EDMX问题实体、框架、问题、EDMX

2023-09-05 04:45:12 作者:安於現狀。

我的方式即可以使用EF CF大项目是通过执行以下操作:

The way I handle large projects using EF CF is by doing the following:

创建一个数据模型(EDMX) 通过清除自定义工具属性禁用该模型模型首先code生成功能 使用实体框架POCO生成扩展名的文件添加相关的模板(T4)到项目 在自定义模板文件遵循我们遵循一定的编码约定

这一切看起来在概念很好,但是,当我们运行项目,EF似乎我们正在使用的模型第一种方法去思考。这不是因为我们不希望EDMX模型映射到任何数据库的情况。我们期望能够在运行时创建的数据库,如果该模型已经改变。

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.

那么,我们怎样才能删除EDMX的数据库映射期望?

So how can we remove database mapping expectations of the EDMX?

推荐答案

由于不使用EDMX。 EDMX是映射。一旦你开始使用EDMX您正在使用模型的第一或数据库第一。 code首先意味着没有EDMX并没有code发电机。在 code 的办法名字的意思是,你应该写一个code。取得code产生的实体和映射的唯一途径首先是当你有一个现有的数据库,并使用EF电动工具,但如果你没有数据库,你没有任何这样的支持。

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.