开发者

Are attributes like Key, ForeignKey etc required in EF CF?

开发者 https://www.devze.com 2023-02-22 20:01 出处:网络
If we use common naming conventions for objects and properties in EF code first approach, do we need to decorate properties by Key, ForeignKey etc. attributes?

If we use common naming conventions for objects and properties in EF code first approach, do we need to decorate properties by Key, ForeignKey etc. attributes?

Does EF rec开发者_开发知识库ognize Id as Pk it selfs?

And Contact property as foreign reference for ContractId?:

    public int ContractId { get; set; }
    public virtual Contract Contract { get; set; }


You do not need to decorate properties in EF if you follow the conventions outlined in this post from the ADO.NET Team Blog on Conventions for Code First

0

精彩评论

暂无评论...
验证码 换一张
取 消