Entity Framework exception "Ambiguous match detected."

Is there a way to use the property hiding in Entity Framework 5.0? If the underlying property is hidden with the new type. In this example, the object identifier is replaced with the new identifier int Id

public abstract class BaseObject : IFBaseObject { [NotMapped] protected virtual object Id { get; set; } public virtual byte[] RowVersion { get; set; } public abstract class BaseObjectInt : BaseObject, IFKeyInt { [Required] [Key] public new virtual int Id { set; get; } public class MessageRef : BaseObjectInt{ public virtual string Category { get; set; } public virtual string message { get; set; } } 

Entity Framework model seems to be working. The database is created as expected. However, when adding values, EF throws a reflection exception. ** ambiguous match found **

 Context.Set<TPoco>().AddOrUpdate(poco); 

If I remove the base property

 // protected virtual object Id { get; set; } 

Then EF works, but I get problems other than EF with generators, since the base type has no identifier.

Track in case of interest.

in System.RuntimeType.GetPropertyImpl (string name, BindingFlagsAttr binding, binder, returnType type, type [], ParameterModifier [] modifiers) in System.Type.GetProperty (string name, BindingFlags bindingAttr) in System.Linq.Enumerable. <> c__DisplayClass12 3.<CombineSelectors>b__11(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator 2.MoveNext () in System.Linq.Enumerable.Aggregate [TSource, TAccumulate] (IEnumerable 1 source, TAccumulate seed, Func ) in System.Data.Entity.Migrations.IDbSetExtensions.AddOrUpdate [TEntity] (DbSet 1 set, IEnumerable 1 identProperties, TEntity [] objects) in System.Data.Entity.Migrations.IDbSetExtensions.AddOrUpdate [TEntity] (set IDb , TEntity objects [])

+1
source share

All Articles