Skip to content

Instantly share code, notes, and snippets.

@davidroth
davidroth / EntityFramwork DbModelStore for loading cached db models.
Created March 31, 2014 06:19
EntityFramwork DbConfiguration with custom DbModelStore for loading cached db models. The custom DbModelStore invalidates out-of-date cache files by comparing the last update date of the cache-xml to the update date of the domain assembly.
public class MyContextConfiguration : DbConfiguration
{
public MyContextConfiguration()
{
MyDbModelStore cachedDbModelStore = new MyDbModelStore(MyContext.EfCacheDirPath);
IDbDependencyResolver dependencyResolver = new SingletonDependencyResolver<DbModelStore>(cachedDbModelStore);
AddDependencyResolver(dependencyResolver);
}
private class MyDbModelStore : DefaultDbModelStore