Entity framework slow to connect to database?

放肆的年华 提交于 2019-12-11 12:02:48

问题


var sw = new Stopwatch();
sw.Start();
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<ImgSimContext>());

using (var db = new ImgSimContext())
{
    SqlConnection.ClearAllPools();
    db.Database.Initialize(force: true);

    sw.Stop();
    Console.WriteLine("Booted in {0}ms", sw.ElapsedMilliseconds);

This takes about 2 seconds, even when the database has already been created. Is there any way I can speed it up?


回答1:


If you are using EF6, then it is a known issue as described here: https://entityframework.codeplex.com/workitem/1749



来源:https://stackoverflow.com/questions/24222789/entity-framework-slow-to-connect-to-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!