EF 4.3 Throwing "An error occurred while getting provider info from the dB. caused by EF using an incorrect con. string. Check Inner Excptin."

10,239

I got the same error, so I went and changed from

AttachDBFilename=|DataDirectory|\aspnet.mdf" 
providerName="System.Data.SqlServerCe.4.0"/>

this line to

AttachDBFilename=|DataDirectory|\aspnet-MvcHopitalPatient-20121116125855.mdf"
providerName="System.Data.SqlClient" />

to the code snippet below

 <connectionStrings>
   <add name="PatientDBContext"
        connectionString="Data Source=|DataDirectory|Patients.sdf"
        providerName="System.Data.SqlServerCe.4.0"/>

    <add name="DefaultConnection" 
        connectionString="Data Source=(LocalDb)\v11.0;
        Initial Catalog=aspnet-MvcHopitalPatient-20121116125855;
        Integrated Security=SSPI;
        AttachDBFilename=|DataDirectory|\aspnet-MvcHopitalPatient-20121116125855.mdf"
        providerName="System.Data.SqlClient" />

 </connectionStrings>
Share:
10,239
Nash
Author by

Nash

I'm Sr. .Net developer and .Net Trainer, disparate to learn new technologies in .Net. So, I feel I'm still dummy in .Net.

Updated on June 04, 2022

Comments

  • Nash
    Nash almost 2 years

    I'm using EF 4.3 Code first. Developing EF Code first application and making CRUD operations done really well on my dev box. Real problem started after I moved the code to WCF service test Server. While I'm trying to insert a record I'm getting

    "An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct"

    Same code in Web Server is working well and its done did by another developer(left the company now), Are there any additional config setting I should do on IIS or in application config before deploying it to WCF TEST Server. I mean do I need to install some thing or verify in GAC ?

    WCF Server: Windows Server 2008 R2

    EF Version : EF 4.3 Code First . Database exists ahead of deployment on WCF test server

    Config File :

    <connectionStrings>
    <add name="MyApplicationDbContext" providerName="System.Data.SqlServerCe.4.0"    connectionString="Server=jmicsq10webdev\web_dev;Database=PlEcom;Integrated Security=SSPI;" />
    </connectionStrings>
    
    <configSections>   
    <section name="entityFramework"   type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </configSections>
    

    I tried also with ProverderName = "system.Data.SqlClient.dll", but didn't fix my problem