在我设置实体模型对象之间的关系后,我得到了模糊的引用错误。 [英] I am getting ambiguous reference error after I set relationship between my entity model objects.
问题描述
当我在实体模型中的表之间没有实体关系时,我没有任何问题。但是在我的edmx模型中设置关系(外键约束)之后,在我更新服务之后,我的服务之间出现了模糊的引用。 br />
Ex作为插图,table1是Service1和Service2之间的模糊引用。
但是table1仅出现在Service1而不是Service2中。 Service2中的table2与Service1的table1有一个实体关系(外键约束)。
如何摆脱这个问题?谷歌对这个问题的帮助不大。
我尝试过:
尝试删除服务并再次添加但没有用,也检查了引用程序集中的重用类型,结果没有用。延迟加载为false。
I had no problem when i had no entity relation ships between my tables in the entity model.But after setting relationship(foreign key constraints) in my edmx model and after i update my services i get ambiguous reference between my services.
Ex as an illustrator table1 is an ambiguous reference between Service1 and Service2.
But table1 is only present in Service1 and not Service2. A table2 in Service2 has an entity relation(foreign key constraint) with table1 of Service1.
How to get rid of this problem?. Google is not helping much with this problem.
What I have tried:
Tried removing the services and adding again but of no use,also checked reuse types in referenced assemblies same result no use.Set lazy loading as false.
推荐答案
一个模糊的引用是当您依赖文件顶部的using语句来预先修复类名时,但是您在多个名称空间中具有相同的类名,因此Visual Studio不知道您的意思。
An ambiguous reference is when you rely on "using" statements at the top of the file to pre-fix class names, however you have the same class name in multiple namespaces so Visual Studio doesn't know which one you mean.
namespace MyNamespaceA
{
public class MyClass
{
public void DoSomething()
{
}
}
}
namespace MyNamespaceB
{
public class MyClass
{
public void DoSomething()
{
}
}
}
using MyNamespaceA;
using MyNamespaceB;
namespace MyApp
{
class Program
{
// this will give an ambiguous reference as MyClass is in both
// MyNamespaceA and MyNamespaceB
MyClass c = new MyClass();
// when this happens you have to be explicit and fully qualify your
// type to include the namespace
MyNamespaceA.MyClass cA = new MyNamespaceA.MyClass();
MyNamespaceB.MyClass cB = new MyNamespaceB.MyClass();
这篇关于在我设置实体模型对象之间的关系后,我得到了模糊的引用错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!