One database, two applications, two dbContext

我怕爱的太早我们不能终老 提交于 2019-12-25 09:17:43

问题


My colleague and me developed a software, divided in two parts. The first is a WPF program while the second is a windows service.

Both of them work on the same database and have their entity framework context.

It works, but now I have to add a new feature giving us some troubles.

I get the addedEntities to do some stuff on it before the saveChanges:

var addedEntities = Entities.dbContext.ChangeTracker.Entries().Where(x => x.State == EntityState.Added && x.Entity.GetType().Name == "mytable").Select(x => x.Entity as mytable).ToList();

This works fine until the windows service writes something in the database. It's like it changhes the dbContext and my program doesn't see the addedEntities anymore.

Do you know how to avoid this issue?

来源:https://stackoverflow.com/questions/41982691/one-database-two-applications-two-dbcontext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!