我首先使用数据库,并且我有一个switch
语句,看起来像这样:
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();
}
这两个数据库非常相似,并且几乎都具有相同的模型。
如果我删除“Two” EDMX文件并注释掉该条件,则OneContext可以完美运行。如果我将TwoContext EDMX文件添加到项目中并再次运行该代码,则在尝试查询
OrganizationObjects.
时,“OneContext”代码将失败我确保每个上下文都使用正确的连接字符串,但是仍然会发生此错误:
最佳答案
The mapping of CLR type to EDM type is ambiguous with EF 6 & 5?
关于c# - 当项目包含多个EDMX文件时,将引发“the entity type is not part of the model for the current context”错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48011690/