Eric Stallcup
Eric Stallcup

Reputation: 389

Weird Ambiguous Invocation Error using Entity Framework T4 Generated Extension

Wondering if anyone could shed some light on why I'm getting this error.

I'm currently writing some code to interact with Entity Objects (using T4 templates to generate the DB contexts), and although the IQueryable<T> Include<T> method is only defined once in the namespace for this specific DB Context (for now, we'll call it Context A), I'm getting an "ambiguous invocation" error whenever I try and use the include extension method in a LINQ query like the following.

In the class containing the RemoveDataFromTestRun() method shown in the picture linked to above, I am also referencing another DB Context (Context B) both in code, and a using Path.To.ContextB.Namespace; declaration. Context B is in an entirely different namespace and project within the same solution housing Context A.

Weird part is If I take out my reference to Context B in this class altogether, I no longer get yelled at because the compiler / re-sharper think I am invoking a method that it claims is ambiguously defined.

Any help is much appreciated!

Upvotes: 0

Views: 1617

Answers (1)

Alex Paven
Alex Paven

Reputation: 5549

Try the go-to-definition tools of Visual Studio (I'm assuming that's what you use); if this is truly a name clash then you'll have two choices for the go-to target. Resharper can also be a big help with navigation, if you have it. If you can't seem to get two different targets, an assembly might have been loaded twice (perhaps a slightly older version, or some other oddity)... I'm afraid beyond that I don't have any other ideas.

Upvotes: 1

Related Questions