Skip to content

Instantly share code, notes, and snippets.

@swax
swax / EntityFramwork DbModelStore for loading cached db models.cs
Last active March 18, 2017 23:01 — forked from davidroth/EntityFramwork DbModelStore for loading cached db models.
EntityFramwork DbConfiguration with custom DbModelStore for loading cached db models. Fork: Instead of invalidating based on date, this version invalidates based on the hash of the model assembly.
public class MyContextConfiguration : DbConfiguration
{
public MyContextConfiguration()
{
HashedDbModelStore cachedDbModelStore = new HashedDbModelStore(MyContext.EfCacheDirPath); // possibly c:\temp\efcache
IDbDependencyResolver dependencyResolver = new SingletonDependencyResolver<DbModelStore>(cachedDbModelStore);
AddDependencyResolver(dependencyResolver);
}
/// <summary>