Fx59
Fx59

Reputation: 61

Database connection issue when deploy on IIS

I have configured 2 connections strings :

  <connectionStrings>
    <add name="ApplicationServices" connectionString="Data Source=.\SQLInstance;Initial Catalog=App;Integrated Security=True" providerName="System.Data.SqlClient"/>
    <add name="AppEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLInstance;Initial Catalog=App;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>

The project is running well when launched from VS.But deployed on IIS, I get "data source keyword not supported" when try to get entities. Membership (so the ApplicationServices connection) works.

Can someone help me to solve this problem ?

Edit : the problem is the same if we use application or web site

Upvotes: 3

Views: 4944

Answers (2)

Fx59
Fx59

Reputation: 61

I finally found the solution. Connection string are not read from IIS configuration but from the web.config.

When create the deployment package, VS do some magic with web.config because it read from web.release.config. When inspected the generated config file, I have remark thaht " have been replaced by &quot;.

So the generated connection string is not valid and we should replace manually & by &.

Thank you anyway for your help

Upvotes: 3

Deltax76
Deltax76

Reputation: 14263

You have to install .NET framework 3.5/4.0 on the server, and then set your web application to use it , then IIS should be able to recognize Entity Framework connection string

Edit: enter image description here

Upvotes: 1

Related Questions