C# EF Code First virtual keyword, what does it do?

后端 未结 2 716
萌比男神i
萌比男神i 2020-12-17 14:30

Why exactly do we need to use the \"virtual\" keyword when declaring a navigation property? I understand that the Code First framework uses it somehow to recognize that the

2条回答
  •  我在风中等你
    2020-12-17 15:08

    Adding virtual allows EF to generate a derived class that overrides the property and returns a set from the database.

提交回复
热议问题