The key component 'Id' is not a declared property on type 'TypeName', when using base class and private setter

后端 未结 2 1789
悲&欢浪女
悲&欢浪女 2021-01-19 17:39

I want to use an abstract base class for entities, which is not mapped on any table:

public abstract class Entity
{
    public virtual int Id { get; private          


        
2条回答
  •  执笔经年
    2021-01-19 18:25

    make setter of id in entity class protected :

    public abstract class Entity
    {
        public virtual int Id { get; protected set; }
    }
    

    i tried this . it will be work

提交回复
热议问题