Hi,
Your question is outside the scope of this Community.
Kindly repost your question in the TechNet SQL Server Forums.
https://social.technet.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver
Cheers.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We are using Code First EntityFramework 6.1.3 (MSSQL 2014) and were having issues with performance of LINQ queries.
The first query would take 3.5secs after applying the patch suggest over here https://www.fusonic.net/en/blog/3-steps-for-fast-entityframework-6.1-code-first-startup-performance/
It worked and now it's 1.5 secs. We are still working on with pre-generated Views to make the LINQ calls under 1 sec.
I download the patch from codeplex.com and compiled EF. Has this been patched in EF released by Microsoft? or any other alternatives?
public class MyContextConfiguration : DbConfiguration { public MyContextConfiguration() { string cachePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\YOUR_APP_NAME\EFCache"; MyDbModelStore cachedDbModelStore = new MyDbModelStore(cachePath); IDbDependencyResolver dependencyResolver = new SingletonDependencyResolver(cachedDbModelStore); AddDependencyResolver(dependencyResolver); } private class MyDbModelStore : DefaultDbModelStore { private static bool useCachedDbModelStore; // Note that you should only enable DbContextStore during normal run scenarios without migrations. Migrations are currently not supported and will crash. public static void Configure(bool useCachedDbModelStore) { MyContextConfiguration.useCachedDbModelStore = useCachedDbModelStore; } public MyContextConfiguration() { // CachedDbModel store wird derzeit nicht immer verwendet, da er z.b. bei Migrations derzeit noch nicht funktioniert (Exceptions im EF Code) if (useCachedDbModelStore) { MyDbModelStore cachedDbModelStore = new MyDbModelStore(MyContext.EfCacheDirPath); IDbDependencyResolver dependencyResolver = new SingletonDependencyResolver(cachedDbModelStore); AddDependencyResolver(dependencyResolver); } } private class MyDbModelStore : DefaultDbModelStore { public MyDbModelStore(string location) : base(location) {} public override DbCompiledModel TryLoad(Type contextType) { string path = GetFilePath(contextType); if(File.Exists(path)) { DateTime lastWriteTime = File.GetLastWriteTimeUtc(path); DateTime lastWriteTimeDomainAssembly = File.GetLastWriteTimeUtc(typeof(TypeInYourDomainAssembly).Assembly.Location); if (lastWriteTimeDomainAssembly > lastWriteTime) { File.Delete(path); Tracers.EntityFramework.TraceInformation("Cached db model obsolete. Re-creating cached db model edmx."); } } else { Tracers.EntityFramework.TraceInformation("No cached db model found. Creating cached db model edmx."); } return base.TryLoad(contextType); } } } }
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Hi,
Your question is outside the scope of this Community.
Kindly repost your question in the TechNet SQL Server Forums.
https://social.technet.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver
Cheers.
They should be able to help you there.
Cheers.
cool ok