mpen
mpen

Reputation: 283203

Entity framework slow to connect to database?

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?

Upvotes: 1

Views: 573

Answers (1)

Diana Nassar
Diana Nassar

Reputation: 2303

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

Upvotes: 2

Related Questions