Entity Framework - Inserting entity with multiple models and databases

前端 未结 1 389
名媛妹妹
名媛妹妹 2020-12-15 00:58

I have my domain split into multiple Entity Framework models. I have some shared entities that span multiple models (named Lookup), however, these are replaced with \"using\

相关标签:
1条回答
  • 2020-12-15 01:42

    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. 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.

    Good luck, Danny.

    0 讨论(0)
提交回复
热议问题