Recently, I have encountered a similar problem. This is due to inheritance in my model. I had a Resource object that received the types Person, Equipment, etc., And in those cases when I redefined a couple of properties, but mistakenly gave them different signatures. I will describe my scenario and hope this helps.
To be able to debug the framework deep enough and see all the values of variables, you will have to disable optimization:
http://blogs.msdn.com/b/kirillosenkov/archive/2009/01/27/how-to-disable-optimizations-during-debugging.aspx
I saw an ambiguous match error when registering a Context in Global.asax like you:
public static void RegisterRoutes(RouteCollection routes) {
Entering the RegisterContext method, I got into System.Web.DynamicData.ModelProviders.EFDataModelProvider, there is a section of code that loads all the objects in the model, moving the inheritance hierarchy to constuctor for EFDataModelProvider.
while (objectStack.Any ()) {EntityType entityType = objectStack.Pop (); if (entityType! = null) {// Update the set of objects when we are in a different root type (type without a base type). if (entityType.BaseType == null) {currentEntitySet = entitySetLookup [entityType]; }
var table = CreateTableProvider(currentEntitySet, entityType); tables.Add(table); } foreach (EntityType derivedEntityType in derivedTypesLookup[entityType]) {
I set a breakpoint here and was able to see that there was an ambiguous match for me when I called CreateTableProvider on my Equipment object (which was obtained from Resource).
Looking back at Stack Trace from the original exception (which I should have done first!), I set a breakpoint in the constructor for System.Web.DynamicData.ModelProviders.EFTableProvider.IsPublicProperty and looked at which property / method / caused something ambiguous coincidence - for me it turned out to be the navigation property Resources (Resources in themselves are a hierarchy), which I redefined in Equipment.
private static bool IsPublicProperty(Type entityClrType, string propertyName) { var property = entityClrType.GetProperty(propertyName); return property != null && property.GetGetMethod() != null; }
In a partial class for equipment, I had:
public partial class Equipment { public new IEnumerable<Resource> Resources {
but in the parent class Resource, Resources was defined as:
public virtual ICollection<Resource> Resources {
When these properties are loaded using .GetProperty (propertyName) in IsPublicProperty, they have the same name but different signatures (because I gave them a different return type by mistake), so it is not clear which shoudl will be loaded based on only by the name. I fixed my mistake and made Resources in my equipment class returning ICollection, and the arrow is no more than an ambiguous match.
Not sure if this will help or not, but if you go the same way, you can determine exactly what is causing an ambiguous match.