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
According to #19340 Reload and ReloadAsync should fire PropertyChanged and PropertyChanging for entities implementing INotifyPropertyChanged and INotifyPropertyChanging respectively.
Though with EF Core 5.0 and the new Castle.Core-proxies implementation this does not happen anymore. With ReactiveUI this is especially cumbersome as I have to manually update states here now.
Subscribe to PropertyChanging and PropertyChanged-events
Those should print PropertyName to Console for Changing and Changed.
run LoadAsync on B-DbSet
Reprint a.B?.Id and observe that the Id has changed
run Entry(a).ReloadAsync() - atleast here PropertyChanged or PropertyChanging should be fired
reprint a.B?.Id and observe nothing has changed (between this and after LoadAsync)
Include verbose output
Running the app produces:
# Scenario 1 #
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 5.0.7 initialized 'AppDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: using change tracking proxies
warn: Microsoft.EntityFrameworkCore.Query[10103]
The query uses the 'First'/'FirstOrDefault' operator without 'OrderBy' and filter operators. This may lead to unpredictable results.
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."BId1"
FROM "A" AS "a"
LIMIT 1
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "b"."Id"
FROM "B" AS "b"
1
Before Reload
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (3ms) [Parameters=[@__p_0='?'], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."BId1"
FROM "A" AS "a"
WHERE "a"."Id" = @__p_0
LIMIT 1
After Reload Reload
1
# Scenario 2 #
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 5.0.7 initialized 'AppDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: using change tracking proxies
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."BId1"
FROM "A" AS "a"
LIMIT 1
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 5.0.7 initialized 'AppDbContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: using change tracking proxies
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "b"."Id"
FROM "B" AS "b"
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (1ms) [Parameters=[@__p_0='?'], CommandType='Text', CommandTimeout='30']
SELECT "a"."Id", "a"."BId1"
FROM "A" AS "a"
WHERE "a"."Id" = @__p_0
LIMIT 1
1
Observe that there is no entry starting with Changing or Changed.
I expect the proxies to implement basic change tracking themselves, and fire PropertyChanged and PropertyChanging accordingly.
Include provider and version information
EF Core version: 5.0.7
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 5.0
Operating system: OS agnostic (observed on .NET Console macOS and .NET WPF Windows)
IDE: IDE agnostic (observed on Visual Studio for Mac 8.10.5 and Visual Studio 2019 16.10.3)
The text was updated successfully, but these errors were encountered:
File a bug
According to #19340 Reload and ReloadAsync should fire PropertyChanged and PropertyChanging for entities implementing INotifyPropertyChanged and INotifyPropertyChanging respectively.
Though with EF Core 5.0 and the new Castle.Core-proxies implementation this does not happen anymore. With ReactiveUI this is especially cumbersome as I have to manually update states here now.
I created a sample reproduction repository: https://github.com/AliveDevil/efcore-reload (additionally attached as efcore-reload-main.zip).
Following is happening:
a.B?.Id
(which is empty)LoadAsync
onB
-DbSeta.B?.Id
and observe that the Id has changedEntry(a).ReloadAsync()
- atleast here PropertyChanged or PropertyChanging should be fireda.B?.Id
and observe nothing has changed (between this and afterLoadAsync
)Include verbose output
Running the app produces:
Observe that there is no entry starting with
Changing
orChanged
.I expect the proxies to implement basic change tracking themselves, and fire PropertyChanged and PropertyChanging accordingly.
Include provider and version information
EF Core version: 5.0.7
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 5.0
Operating system: OS agnostic (observed on .NET Console macOS and .NET WPF Windows)
IDE: IDE agnostic (observed on Visual Studio for Mac 8.10.5 and Visual Studio 2019 16.10.3)
The text was updated successfully, but these errors were encountered: