switch (site){ case Site.One: using (OneContext one = new OneContext()) return one.OrganizationObjects.SingleOrDefault(x => x.u_name == orgname)?.g_org_ID; case Site.Two: using (TwoContext two = new TwoContext()) return two.OrganizationObjects.SingleOrDefault(x => x.u_name == orgname)?.g_org_ID; default: throw new NotImplementedException();}
两个数据库非常相似,并且几乎具有所有相同的模型.
如果我删除“两个”EDMX文件并注释掉条件,那么OneContext可以正常工作.如果我将TwoContext EDMX文件添加到项目并再次运行代码,则“OneContext”代码在尝试查询OrganizationObject时失败.
我确保每个上下文都使用正确的连接字符串,但仍会出现此错误:
解决方法总结Workaround: Change a property on one of the two IDentical classes.
EF matches on class name AND class propertIEs. So I just changed a
property name on one of the EF objects,and the error is gone.As @Entrodus commented on one of the other answers:
EF collision happens only when two classes have the same name AND the
same set of parameters.The mapping of CLR type to EDM type is ambiguous with EF 6 & 5?
以上是内存溢出为你收集整理的c# – “实体类型不是当前上下文模型的一部分”当项目包含多个EDMX文件时抛出错误全部内容,希望文章能够帮你解决c# – “实体类型不是当前上下文模型的一部分”当项目包含多个EDMX文件时抛出错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)