开发者

Defining primary key as virtual in Entity Framework

What's the benefit of defining the primary key attribute as virtual in entity Framework?

AFAIK, virtual is used for lazy loading in navigation properties and for change tracking in other properties. But we don't need any of the mentioned fe开发者_开发技巧atures in primary keys.

So, Is it any use to define primary keys virtual?


Change tracking proxies are created only if all non-navigation mapped properties are virtual. MSDN:

Each property that is mapped to a property of an entity type in the data model must have non-sealed (NotOverridable in Visual Basic), public, and virtual (Overridable in Visual Basic) get and set accessors.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜