3

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

4
  • Are you sure you are using the second connection string in EF not the first? Commented May 18, 2011 at 7:13
  • Yes else it will not working on visual studio, no ? Commented May 18, 2011 at 13:50
  • Try to remove the first connection string, and check what will happen in visual studio and in IIS Commented May 18, 2011 at 19:40
  • Nothing work . EF use the good connection string: public AppEntities() : base("name=AppEntities", "AppEntities") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } Commented May 21, 2011 at 7:18

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

3 Comments

.Net framework is installed. We have install visual studio on the server (virtual machine for test). When running with vs (build & run), all is good. When running from IIS (after deployment thanks vs), it's possible to login.But impossible to retrieve data : we got the error.
I assume that you're using .NET 4.0 on IIS 6.x. As I said, you have to config IIS to allow your web application to use properly version. Right click on your web app in IIS, choose property, in ASP.NET tab, set version to .NET 4.0 :). That should work
We use II 7 with .NET 3.5.1. The application pool is running in v4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.