I\'ve got the following domain entity:
public string Reference { get; private set; }
public int SupplierId { get; private set; }
public int BranchId { get; p
It's possible to configure a backing field usage for a navigation property, but not via Property
method which is for primitive property, and not via fluent API (doesn't exist at this time), but directly through mutable model metadata associated with the relationship:
modelBuilder.Entity<PurchaseOrder>()
.HasMany(e => e.LineItems)
.WithOne(e => e.PurchaseOrder) // or `WithOne() in case there is no inverse navigation property
.Metadata.PrincipalToDependent.SetPropertyAccessMode(PropertyAccessMode.Field); // <--
You can also set the mode for all entity navigation properties (you can still override it for individual properties) by using:
modelBuilder.Entity<PurchaseOrder>()
.Metadata.SetNavigationAccessMode(PropertyAccessMode.Field);