Entity Framework gives me the old data although i changed them

后端 未结 1 695
独厮守ぢ
独厮守ぢ 2021-01-22 03:03

I have a strange problem with the Entity Framework:

I have a SQL Server database on a Windows Server and I access it via my app through Entity Framework.

Now I c

相关标签:
1条回答
  • 2021-01-22 03:46

    Entity Framework caches objects internally in a DbContext instance. Those are meant to be short-lived, the purpose of the caching is so that every time you look up an entity with the same ID you get the same actual instance of said entity back.

    This means that when using Entity Framework, you shouldn't store a DbContext in a static field. Create a new one for every request.

    0 讨论(0)
提交回复
热议问题