First, spec. We use MVC5, .NET 4.5.1, and Entity framework 6.1.
In our MVC5 business application we have a lot of repetitive CRUD code. My job is to \"automate\" mos
If you are defining the BaseEntity class, you could add a virtual read only property that returns the actual ID property. I beleive EF treats read only properties as "computed", so they are not stored to the db.
public abstract class BaseEntity where TSubclass : BaseEntity
{
public abstract object ID { get; }
public virtual Expression> UpdateCriterion()
{
return entity => entity.ID;
}
}
public partial class Foo : BaseEntity
{
public Int32 FooId { get; set; }
public override object ID { get { return FooId; } }
}
Just a thought - I only tried compiling in LinqPad and checking the value of a call to UpdateCriterion. :)