简体   繁体   English

底层提供程序在开放实体框架上失败

[英]The underlying provider failed on open entity framework

I am unsing entity framework in my web application. 我在我的Web应用程序中没有实体框架。 Earlier everything was working fine. 早些时候一切都很好。 But then I deleted database from Sql Server. 但后来我从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? 如果我们从Sql Server中删除数据库并再次运行应用程序,是否再次创建数据库?

Entity framework will recreate your database on application start assuming the following: 假设以下内容,实体框架将在应用程序启动时重新创建数据库:

  • You have permission to create databases in SQL 您有权在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) 您正在为数据库使用CodeFirst或ModelFirst策略(即,如果您从现有数据库生成EDMX,它将不会为您重新创建它)

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 用于设置典型身份验证的演示: 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();

I had a similar error and it was due to the connection problem. 我有类似的错误,这是由于连接问题。 Usually you need to open your *.EDPS file under your entity (EDML) and check your connection string and make sure it has got a correct setting especially your Default Oracle home. 通常,您需要在您的实体(EDML)下打开* .EDPS文件并检查您的连接字符串并确保它具有正确的设置,尤其是您的默认Oracle主目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM