How to force Entity Framework to always get updated data from the database?

Saravana

I am using EntityFramework.Extended library to perform batch updates. The only problem is EF does not keep track of the batch updates performed by the library. So when I query the DbContext again it does not return the updated entities.

I found that using AsNoTracking() method while querying disables the tracking and gets fresh data from the database. However, since EF does not keep track of the entities queried with AsNoTracking(), I am not able to perform any update on the queried data.

Is there any way to force EF to get the latest data while tracking changes?

PlTaylor

Please try this to refresh a single entity:

Context.Entry<T>(entity).Reload()

Edit: To get fresh data for a collection of entities is worth trying to dispose the DbContext instance after each request.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get Single Value From Database through Entity Framework

From Dev

How to Fetch Data from database using Entity Framework 6

From Dev

Retrieving data from database using Entity Framework

From Dev

Data from database by Entity Framework to list - WCF

From Dev

How to get data from child to parent entity framework core?

From Dev

How to load an object from the database (Entity Framework)

From Dev

How to Get Joined Table Data Entity Framework

From Dev

Can't get Entity Framework MVC app to seed data to database

From Dev

Data is not updated in database, using C#,WPF, Entity framework and Visual studio 2012

From Dev

Data isn't being updated in Entity Framework

From Dev

Get first N Rows from Database using Entity Framework

From Dev

Entity Framework add local data to list from database

From Dev

Entity Framework core 2.0.3 not giving latest data from Database

From Dev

display data from database in datagridview with entity framework in c#

From Dev

WebAPI issue while retrieving data from database using Entity Framework

From Dev

Get multiple data from tables Using Entity Framework data model

From Dev

How to get id from entity for Auditlog in Entity Framework 6

From Dev

retrieve data from database that is updated

From Dev

How to get data from the database?

From Dev

How to force Entity Framework insert records to clean database every solution run

From Dev

How to count nested collection from database using Entity Framework

From Dev

How to update database from DataGrid using Entity Framework

From Dev

How can I programmatically generate Entity Framework classes from a database?

From Dev

How to count nested collection from database using Entity Framework

From Dev

How to insert 200 rows into database from Entity Framework in one hit

From Dev

Get data from nested table using entity framework

From Dev

I can not get data from SQL Server via Entity Framework

From Dev

How to make sure the database server is always available while using Entity Framework?

From Dev

Entity Framework: how do I prevent an attached object from getting validation errors on properties not updated?

Related Related

  1. 1

    How to get Single Value From Database through Entity Framework

  2. 2

    How to Fetch Data from database using Entity Framework 6

  3. 3

    Retrieving data from database using Entity Framework

  4. 4

    Data from database by Entity Framework to list - WCF

  5. 5

    How to get data from child to parent entity framework core?

  6. 6

    How to load an object from the database (Entity Framework)

  7. 7

    How to Get Joined Table Data Entity Framework

  8. 8

    Can't get Entity Framework MVC app to seed data to database

  9. 9

    Data is not updated in database, using C#,WPF, Entity framework and Visual studio 2012

  10. 10

    Data isn't being updated in Entity Framework

  11. 11

    Get first N Rows from Database using Entity Framework

  12. 12

    Entity Framework add local data to list from database

  13. 13

    Entity Framework core 2.0.3 not giving latest data from Database

  14. 14

    display data from database in datagridview with entity framework in c#

  15. 15

    WebAPI issue while retrieving data from database using Entity Framework

  16. 16

    Get multiple data from tables Using Entity Framework data model

  17. 17

    How to get id from entity for Auditlog in Entity Framework 6

  18. 18

    retrieve data from database that is updated

  19. 19

    How to get data from the database?

  20. 20

    How to force Entity Framework insert records to clean database every solution run

  21. 21

    How to count nested collection from database using Entity Framework

  22. 22

    How to update database from DataGrid using Entity Framework

  23. 23

    How can I programmatically generate Entity Framework classes from a database?

  24. 24

    How to count nested collection from database using Entity Framework

  25. 25

    How to insert 200 rows into database from Entity Framework in one hit

  26. 26

    Get data from nested table using entity framework

  27. 27

    I can not get data from SQL Server via Entity Framework

  28. 28

    How to make sure the database server is always available while using Entity Framework?

  29. 29

    Entity Framework: how do I prevent an attached object from getting validation errors on properties not updated?

HotTag

Archive