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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 19:24:42
phil soady

EF likes to access all keys. Try using protected so the assembly can access the ID but externals cant. Seems like a reasonable question for the EF team to me.

See related post Does the Entity Framework code first support readonly navigation property

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!