简体   繁体   中英

How to share Entity Framework between two applications?

I have four VS projects in the same solution with the following architecture:

  • Admin Application -> Service -> Repository
  • Final User Application -> Service - Repository

Admin and User project share the same layers Service / Repository but each one has its own server ( user.domain.com and admin.domain.com ) so they are in different IIS pools.

I publish them separately, however, when I make some change in admin it does not take any effect in the final user's app due the Entity Framework caching. My repository uses a static context, I cannot lose the entities changes so I cannot turn it into a local context.

I tried this in user's app:

foreach (var entity in _context.ChangeTracker.Entries())
{
     entity.Reload();
}

worked but the application got too slow.

Is there a good way to identify database changes using the same EF layer in two different applications?

Or disable only User 's app caching..

I am using EF6 and .NET 4.6.1

Thanks

My repository uses a static context

Don't do that. The context should be transient, or scoped to the HTTP request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM