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
I enabled lazy loading in my project. Say I have the following model
public class BillingInformation {
public int Id {get;set;}
public virtual Address Address {get;set;}
}
public class Address {
public int Id {get;set;}
}
When I set Address property to null, the context does not consider that a change. If I access the property (call its getter) before setting it to null, the entity is marked as modified and the foreign key is set to null in the database.
Further technical details
EF Core version: 2.1.4
Database Provider: Pomelo.EntityFrameworkCore.MySql v2.1.2
Operating system: Windows 10 v1803
IDE: Visual Studio 2017 15.9
The text was updated successfully, but these errors were encountered:
@pikausp There are a couple of reasons why this is the case:
Lazy-loading proxies are setup to handle what is needed for lazy-loading. Setting a property to null is a change-tracking behavior, which is being tracked by Implement change tracking proxies #10949. We considered doing this anyway, but...
Making this behavior consistent for principal/dependent ends and reference/collection navigation properties is non-trivial. So setting the FK to null for a simple case like above is doable, but deciding what to do when, for example a principal-to-dependent to null is more difficult.
Reopening this based on discussion here: #19437 (comment). This should be fixed so it works consistently with both change tracking proxies and manually implemented notification entities.
I enabled lazy loading in my project. Say I have the following model
When I set Address property to null, the context does not consider that a change. If I access the property (call its getter) before setting it to null, the entity is marked as modified and the foreign key is set to null in the database.
Further technical details
EF Core version: 2.1.4
Database Provider: Pomelo.EntityFrameworkCore.MySql v2.1.2
Operating system: Windows 10 v1803
IDE: Visual Studio 2017 15.9
The text was updated successfully, but these errors were encountered: