Click here to Skip to main content
15,891,859 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 20-Mar-16 18:12pm
v5

1 solution

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.

C#
namespace MyNamespaceA
{
    public class MyClass
    {
        public void DoSomething()
        {
        }
    }
}

namespace MyNamespaceB
{
    public class MyClass
    {
        public void DoSomething()
        {
        }
    }
}


C#
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();
 
Share this answer
 
Comments
Yogi@FLG 11-Mar-16 6:58am    
But Myclass is only present in MyNamespaceA and not present in MyNamespaceB,
Myclass in my code is refering to an entity model object.
F-ES Sitecore 11-Mar-16 7:15am    
If you hover over the offending class in VS it usually lists all the possible references it might be.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900