【问题标题】:Entity framework - having the same table in more than one edmx实体框架 - 在多个 edmx 中拥有同一张表
【发布时间】:2012-11-25 12:57:38
【问题描述】:

我有两个 edmx 文件。
两者都包含表“applicationType”。
这意味着我有两个具有不同命名空间的对象 applicationType。 当我尝试从一个查询时
我收到以下错误 -

 "Schema specified is not valid. Errors: \r\nMultiple types with the name 
 'ApplicationType' exist in the EdmItemCollection in different namespaces.  
  Convention based mapping requires unique names without regard to namespace 
  in the EdmItemCollection.\r\nThe relationship   
  'myModel.FK_ApplicationAttribute_ApplicationType' was not loaded because the type 
  'myModel.ApplicationType' is not available.\r\n"} 
   System.Data.EntityException {System.Data.MetadataException}

谁能建议如何查询它?

【问题讨论】:

    标签: entity-framework entity-framework-4


    【解决方案1】:

    如果两个模型位于同一个命名空间中,则这些对象必须具有不同的名称。例如:

    模型 1 - 命名空间:myApp - 表:applicationType - entityName:applicationType

    在您的第二个模型中,您必须使用另一个命名空间,或者另一个 entityName。

    【讨论】:

      【解决方案2】:
      1. 打开你的一张 edmx 图

      2. 右键单击复制的实体并将其重命名

      3. 保存,构建项目

      4. 调整使用您刚刚重命名的实体的代码可能出现的错误(仅更新实体名称)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-05
        相关资源
        最近更新 更多