Search code examples
c#wpf

Entity Framework: No database connection has been configured for this model


I was trying to update the return values of a stored procedure but for some reason Entity Framework tells me there is no connection for this model (cfr. first screenshot). Due to this problem I am unable to update the function nor the complex type.

Function import menu

Whenever I click the button Update Model from Database... I am prompted with the Update Wizard.

Choose data connection menu

This is what the connection string looks like in the app.config file.

  <connectionStrings>
    <add name="WeighingEntities" 
         connectionString="metadata=res://*/Model.Weighing.WeighingModel.csdl|res://*/Model.Weighing.WeighingModel.ssdl|res://*/Model.Weighing.WeighingModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=sql2016;Initial Catalog=db2;Persist Security Info=True;User ID=user;Password=password;MultipleActiveResultSets=True;Application Name=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" />
  </connectionStrings>

This is a WPF application, I am using EntityFramewrok 6.2.0 and the project is using the .NET Framework 4.5 and my IDE is Visual Studio 2017. This was working previously. The database is working properly. I tried to add the data connection again using the Update Wizard. I did delete and recreate the .edmx. I also tried to delete the connection string in the file and then use the Update Wizard in order to recreate it.

None of my attemps did change anything I am still getting the message:

No database connection has been configured for this model.

How can I get EF6 to work again?


Solution

  • I have a workaround but it does not solve the underlying issue:

    • Delete the Stored Procedure, the Function Import and the Complex Type in the .edmx file
    • Use the UpdateWizard to reimport the StoredProcedure