area-F#area-model-buildingarea-proxiescustomer-reportedhelp wanted
説明
I'm trying to use EF Core 2.1 from F# with lazy loading proxies, but keep running into:
No field was found backing property 'hypervisor' of entity type 'Alert'. Lazy-loaded navigation properties must have backing fields. Either name the backing field so that it is picked up by convention or configure the backing field to use.
When we follow the recommended workaround to add abstract fields, they end up with an appended @ symbol.
In this case, I have:
[<ForeignKey("HypervisorID")>]
default val hypervisor : Hypervisor = null with get, set
abstract member hypervisor : Hypervisor with get, set
If view it in JustDecompile to C# or similar app, the field is:
internal Hypervisor hypervisor@;
[ForeignKey("HypervisorID")]
public override Hypervisor hypervisor
{
get
{
return this.hypervisor@;
}
set
{
this.hypervisor@ = value;
}
}
This is the behavior of F# explicit fields.
All the fields I have are this way. Is there a way to map F# explicit fields so that EF 2.1 lazy loaded proxies work? This doesn't work, but this was the direction I was going:
override this.OnModelCreating builder =
base.OnModelCreating builder
for entity in builder.Model.GetEntityTypes() do
for property in entity.GetProperties() do
sprintf "%s@" property.FieldInfo.Name |> property.SetField