问题
Is there a way to get notified, when the database is newer than the DbContext of EF?
In my case I develop an application that can be installed on several computers. They use the same Database. Since these applications are supposed to run the whole day, chances are high that one is updating data and the other instance of the application is still holding old data in its DbContext.
Now I could implement some checking for new data each minute or so. Or checking for new data each time the user does some I input or comes back to the application. But isn't there an event based solutions available?
if this is important: My Database is SQLite and the ADO.NET provider is System.Data.SQLite (from the SQLite developers)
回答1:
AFAIK SQLite has no "push notifications" mechanism, so this question really has nothing to do with EF. But to answer your question directly: No. If you were using SQLServer there is some stuff you can do with the SqlCacheDependency
which is similar to what you're asking, but even that is not supported by the Entity Framework.
It's your responsibility to manage concurrency and update the data as needed.
来源:https://stackoverflow.com/questions/14407195/does-entity-framework-system-data-sqlite-provide-a-database-changed-from-outsi