navigation property should be virtual - not required in ef core?
c#, entity-framework, entity-framework-core, navigation-properties, virtual
Solution
`virtual` was never required in EF. It was needed only if you want lazy loading support.
Since Lazy loading is not yet supported by EF Core, currently `virtual` have no special meaning. It would when (and if) they add lazy loading support (there is a plan for doing so).
Update: Starting with EF Core 2.1, Lazy loading is now supported. But if you don't add Microsoft.EntityFrameworkCore.Proxies package and enable it via `UseLazyLoadingProxies`, the original answer still applies.
However if you do so, the thing's totally changed due to the lack of the opt-in control in the initial implementation - it requires all your navigation properties to be `virtual`. Which makes no sense to me, you'd better not use that until it gets fixed. If you really need lazy loading, use the alternative Lazy loading without proxies approach, in which case again `virtual` doesn't matter.
Problem
As I remember in EF navigation property should be virtual: ``` public class Blog { public int BlogId { get; set; } public string Name { get; set; } public string Url { get; set; } public string Tags { get; set; } public virtual ICollection<Post> Posts { get; set; } } ``` But I look at EF Core and don't see it as virtual: ``` public class Student { public int ID { get; set; } public string LastName { get; set; } public string FirstMidName { get; set; } public DateTime EnrollmentDate { get; set; } public ICollection<Enrollment> Enrollments { get; set; } } ``` Is it not required anymore?