You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make lazy-loading work without direct field access #13084
Currently lazy loading proxies will look for fields no matter what, this hinders libraries with custom properties to work (e.g. Catel ), at least can lazy loading adapt to the already existing modelBuilder.UsePropertyAccessMode method ?
=================
EF Core version: 2.1.2
Database Provider: Sqlite
Operating system: Win10 x64
IDE: Visual Studio 2017 15.8.1
@bigworld12 EF writing directly to fields is currently required for lazy-loading to work. Can you show some examples of properties for which this is causing issues?
@ajcvickers
for example in Catel.Core which uses dependency-property-like properties
a typical property in the model is defined like this
// <summary>
/// Gets or sets the name.
/// </summary>
public string Name
{
get { return GetValue<string>(NameProperty); }
set { SetValue(NameProperty, value); }
}
/// <summary>
/// Register the Name property so it is known in the class.
/// </summary>
public static readonly PropertyData NameProperty = RegisterProperty("Name", typeof(string), string.Empty);
so you don't have direct access to the backing field, which adds features like (notification, saving and resetting object state, validation, etc..)
so EntityFrameworkCore will not work with these types of properties as it's only looking for fields, not the access mode defined in modelBuilder.UsePropertyAccessMode
We discussed this in triage, and decided that we can support this through #2968. Keeping this issue open to track configuration of lazy-loading with this mechanism once implemented.
changed the title [-]Lazy Loading proxies use fields even though UsePropertyAccessMode is set to PropertyAccessMode.Property[/-][+]Make lazy-loading work without direct field access[/+]on Aug 28, 2018
Activity
ajcvickers commentedon Aug 23, 2018
@bigworld12 EF writing directly to fields is currently required for lazy-loading to work. Can you show some examples of properties for which this is causing issues?
bigworld12 commentedon Aug 23, 2018
@ajcvickers
for example in Catel.Core which uses dependency-property-like properties
a typical property in the model is defined like this
so you don't have direct access to the backing field, which adds features like (notification, saving and resetting object state, validation, etc..)
so EntityFrameworkCore will not work with these types of properties as it's only looking for fields, not the access mode defined in
modelBuilder.UsePropertyAccessModei did some searching and probably that's where problems happen
https://github.com/aspnet/EntityFrameworkCore/blob/release/2.2/src/EFCore.Proxies/Proxies/Internal/ProxyBindingRewriter.cs#L118
ajcvickers commentedon Aug 28, 2018
We discussed this in triage, and decided that we can support this through #2968. Keeping this issue open to track configuration of lazy-loading with this mechanism once implemented.
[-]Lazy Loading proxies use fields even though UsePropertyAccessMode is set to PropertyAccessMode.Property[/-][+]Make lazy-loading work without direct field access[/+]