且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架 - 插入多个模型和数据库实体

更新时间:2023-02-13 11:10:32

如果你的模型的每个部分写入到一个单独的数据库,那么也许EDMX文件应该不知道对方的存在(约实体或关系到做实体不属于他们)。

如何尝试以下方法之一:
(要结束了相同的实体类的每一个部分,而且使EF无视它们之间的连接。)

If each part of your model is written to a separate database, then perhaps the edmx files should not know about each other (about entities or relationship to entities that do not belong to them).

How about trying one of the following approaches:
(To end up with same entities classes for each part, but make EF oblivious of connections between them.)

  1. 从EDMX删除usings+取消自动生成和创建类自己。
  2. 从EDMX删除usings+修改T4模板创建的类时读取多个EDMX。
  3. 复制EDMX文件,一边让你有两套edmxs的。
     3.A.使用#1自动生成实体。
     3.B.的修改集#2通过删除usings和用于代库类(objectsets)的。
  1. Remove the "usings" from edmx + cancel auto generation and create classes yourself.
  2. Remove the "usings" from edmx + modify t4 template to read more than one edmx when creating the classes.
  3. Copy edmx files aside so you have two sets of edmxs.
    3.a. Use set #1 for auto generation of entities.
    3.b. Modify set #2 by removing the "usings" and use for generation of repository classes (objectsets).

让我知道,如果这些作品的。

Let me know if one of these works.

祝你好运, 丹尼。