I'm having an issue here with Entity Framework 5
In my program I have a base class defined as below:
public abstract class CoreProduct
{
public abstract decimal Price { get; set; }
public abstract decimal CategoryID { get; set; }
public abstract decimal Quantity { get; set; }
public decimal CalculatePrice()
{
//Code to calculate the price here
}
}
I want to have specific classes auto generated by Entity Framework to inherit from this class, so that I can calculate their prices given the quantity, etc.
So what I did was to create a new file for the normal products and did this:
public partial class Product : CoreProduct
{
public override decimal Price { get; set; }
public override decimal CategoryID { get; set; }
public override decimal Quantity { get; set; }
}
But since the fields Price, CategoryID and Quantity are auto generated by Entity Framework, I have to go delete them from the file auto generated by EF, then everything works.
My problem is that every time I have to update my model at all, the code gets auto generated yet again and I have to go manually re-delete all the fields for all of the classes the inherit my CoreProduct class.
What would be the better way of achieving this so I don't have to manually delete 50 fields every time I have to update my model?