Entity Framework The underlying provider failed on Open

后端 未结 19 1717
挽巷
挽巷 2020-12-02 20:12

Below is my connection string:

connectionString=\"metadata=res://*/EDMX.Test.csdl|res://*/EDMX.Test.ssdl|res://*/EDMX.Test.msl;provider=System.Data.Sq

相关标签:
19条回答
  • 2020-12-02 20:47

    Please check the following things first.

    While generating the Edmx you would have given a name to you connection string. that gets into the app config of the project with the Entity.

    Have you copied the same connection string to your main Config file. Also the Name should be same as which you have given while generating the EDMX file.

    0 讨论(0)
  • 2020-12-02 20:47

    My client reported this error. I found that he was messing with *.ldf files. He copied *ldf file on one database and renamed it to match a second database (which I asked him to place in a folder).

    I replicated the same scenario, and got this same error in my development system. Error got fixed after deleting the *ldf file(s).

    0 讨论(0)
  • 2020-12-02 20:48

    Always check for Inner Exception if any. In my case Inner Exception turned out to be really helpful in figuring out the issue.

    My site was working fine in Dev Environment. But after i deployed to production, it started giving out this exception, but the Inner Exception was saying that Login failed for the particular user.
    So i figured out it was something to do with the connection itself. Hence tried logging in using SSMS and even that failed.

    Eventually figured out that exception showed up for the simple reason that the SQL server had only Windows Authentication enabled and SQL Authentication was failing which was what i was using for Authentication.

    In short, changing Authentication to Mixed(SQL and Windows), fixed the issue for me. :)

    0 讨论(0)
  • 2020-12-02 20:50

    If you are using a local .mdf file, probably a sync software such Dropbox attempted to sync two log files (.ldf) in two different computers you can delete the log files from the bin Directory and make sure the .mdf properties->Copy to Output Directory ->Copy if newer that will copy the selected DB file and it's log to the bin Directory. !Alert- if your DB file has only changed in the bin Directory all the changes ill be discarded!

    0 讨论(0)
  • 2020-12-02 20:54

    open SQL Server Configuration Manager then click on sql server services a list will be displayed from the list right click sql server and click on start

    0 讨论(0)
  • 2020-12-02 20:55

    In my case, I resolved the error by adding connection password in the connection string.

    While setting up the EF model, I had selected the option to exclude sensitive data from connection string. So, the password was not included initially.

    0 讨论(0)
提交回复
热议问题