EF Core allows you to model entity types that can only ever appear on navigation properties of other entity types. These are called owned entity types. The entity containing an owned entity type is its owner.
In EF Core 3.1, the dependent end of a one-to-one relationship was always considered optional.
This was most apparent when using owned entities.
Let's consider the following model.
public class Customer{ public int Id { get; set; } public string Name { get; set; } public Address HomeAddress { get; set; } public Address BillingAddress { get; set; }}public class Address{ public string Street { get; set; } public string City { get; set; } public string State { get; set; } public string Country { get; set; }}
Here is the implementation of the context class which contains the configuration.
Now when you create migration or call the EnsureCreated method, you will see that it will now include non-nullable columns for the required properties of the required dependent.