How do I clear tracked entities in entity framework

后端 未结 6 1225
不知归路
不知归路 2020-12-04 20:50

I am running some correction code that runs over a big pile of entities, as it progress its speed decreases, that is because the number of tracked entities in the context in

6条回答
  •  执笔经年
    2020-12-04 21:12

    I'm running a windows service that updates values every minute and I have had the same problem. I tried running @DavidSherrets solution but after a few hours this got slow as well. My solution was to simply create a new context like this for every new run. Simple but it works.

    _dbContext = new DbContext();

提交回复
热议问题