How to mark identity column properly with Entity Framework 6.1?

后端 未结 3 1722
滥情空心
滥情空心 2021-01-04 16:29

I\'ve seen many posts and answers regarding how to mark a field as the identity column. Many of them are outdated and are targeting older versions of Entity Framework.

3条回答
  •  粉色の甜心
    2021-01-04 17:08

    Either, your choice. I use a mixture of the two: attributes for simple things like this, and the modelBuilder for more complex scenarios the attributes don't cover. They're both equally valid, and you'll see that under the covers (EF 'conventions'), the attributes are used to tell the modelBuilderwhat to do.

提交回复
热议问题