Entity Framework - refresh objects from database

前端 未结 3 854
北荒
北荒 2021-02-14 09:53

I\'m having trouble with refreshing objects in my database. I have an two PC\'s and two applications.

On the first PC, there\'s an application which communicates with my

3条回答
  •  情话喂你
    2021-02-14 10:43

    As of EF 4.1 you can use AsNoTracking() method on your entities.

    return myEntities.Measurements.AsNoTracking();
    

    Note that AsNoTracking() will not add the entities to your context for tracking, but merely return them fresh from your data store.

    For more info see http://blogs.msdn.com/b/adonet/archive/2011/02/05/using-dbcontext-in-ef-feature-ctp5-part-11-load-and-asnotracking.aspx

提交回复
热议问题