我有定義的主鍵的模型,但現在我需要從我的抽象類繼承這個類。問題是,主鍵也需要抽象類。 PK的屬性名稱不同,它們必須有所不同。實體框架代碼第一個 - 沒有主鍵的抽象模型類
例子:
public abstract class AbstractModelClass
{
public int AbstractModelClassId { get; set; } // this key is required but I want him to not to be because I don't want to have 2 PK's
public string Prop1 { get; set; }
}
public class ModelClass : AbstractModelClass // before this class was not inherited but now I need this
{
public int ModelClassId { get; set; }
public int Prop2 { get; set; }
}
這是一個關於類似[問題](https://stackoverflow.com/a/45834364/5148649)的建議, – Scrobi