实体框架缓慢连接到数据库

实体框架缓慢连接到数据库

本文介绍了实体框架缓慢连接到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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);

即使已创建数据库,大概需要2秒钟。有什么办法可以加快吗?

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

推荐答案

如果您使用EF6,那么这里是一个已知的问题:

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

这篇关于实体框架缓慢连接到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 15:05