The underlying provider failed on open entity framework

asp.net entity-framework sql-server

Question

I am unsing entity framework in my web application. Earlier everything was working fine. But then I deleted database from Sql Server. After that whenever I run the application, I get the following exception :

The underlying provider failed on open entity framework  

Isn't it true that if we delete the database from Sql Server and again run the application, database is again created?

1
3
7/23/2017 9:24:57 AM

Accepted Answer

Can you show some details about connection string. I basically want to check the authentication you are using. Demo for setting a typical authentication : http://msdn.microsoft.com/en-us/library/ff649314.aspx

Another possibility can be with connection pooling. Try explicitly closing the connection(if there are any open connections)

db.Database.Connection.Close();
3
8/3/2012 10:44:22 AM

Popular Answer

Entity framework will recreate your database on application start assuming the following:

  • You have permission to create databases in SQL
  • A connection string is specified correctly (if it was working before this should be fine)
  • You are using CodeFirst or ModelFirst strategies for databases (ie if you generated an EDMX off an existing database it wont recreate it for you)


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow