Reputation: 3284
In Fluent Api at EF Core 2.0.0, there aren't any methods HasRequired
and HasOptional
, and i have tow Models, Person and Employee:
public class Person
{
public int Id { get; set; }
public int EmployeeId { get; set; }
public virtual Employee Employee { get; set; } // Optional
}
public class Employee
{
public int Id { get; set; }
public int PersonId { get; set; }
public virtual Person Person {get; set; } // Required
}
Person
May to have Employee:Optional
Employee
Should have Person:Required
How to apply these convetions in database.
Upvotes: 5
Views: 1555
Reputation: 337
You could just specify int? as EmployeeId property type.
BTW, no need to make navigation properties virtual.
Upvotes: 1