dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.66k stars 3.15k forks source link

Ability to refresh a context from the database #16491

Open knightmeister opened 5 years ago

knightmeister commented 5 years ago

I'm raising this as I've seen #11706 and #2296 are closed.

I require this functionality for GUI applications, for which EF Core is a viable target - specifically via Xamarin and UWP.

It is possible with EF6 to refresh the context by using Refresh(RefreshMode.StoreWins)

I totally understand that contexts are suggested per-unit of work however GUI applications have long living components (such as the main screen) for which a unit of work isn't suitable.

At this stage I have implemented an internal message bus which indicates when a single entity should be reloaded, but it would be nice to be able to refresh the store and all tracked entities in EF Core.

ajcvickers commented 5 years ago

Triage: Putting this on the backlog to consider behaviors for DbContext in EF Core similar to ObjectContext.Refresh in the old stack.

audacity76 commented 4 years ago

@ajcvickers Any update on this issue?

ajcvickers commented 4 years ago

@audacity76 This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 5.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

QutfulloOchilov commented 3 years ago

@ajcvickers Any update on this issue?

DamirLisak commented 1 year ago

Will it be also possible to refresh only the affected objects that have been queried from the database like in EF 4 ? In a similar way like https://learn.microsoft.com/en-us/dotnet/api/system.data.objects.objectquery-1.execute?view=netframework-4.8.1

query.Include(c => c.RelatedData)...;
query.MergeOption = MergeOption.OverwriteChanges; // or
query.Execute(MergeOption.OverwriteChanges);
ajcvickers commented 1 year ago

@DamirLisak That's not decided yet.

DamirLisak commented 1 year ago

@ajcvickers When can we expect a decision? ( I'm asking because we urgently need this feature ;-) ) If not, do you have a suggestion for a "MergeOption-Workaround" for refreshing entities?

roji commented 1 year ago

This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 8.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you.

hodaschiy commented 3 months ago

@ajcvickers Any update on this issue?

roji commented 3 months ago

@hodaschiy see the comment just above.