LeBlues
LeBlues

Reputation: 301

MVC 4 Entity Framework Web config

I have an application which connects to our SQL Server 2008 enterprise.

My config file contains:

name="patbase" connectionString="Data Source=pbsqlserver1;Initial Catalog=patentbase;Trusted_Connection=True;;Application Name=PatBase Images;" providerName="System.Data.SqlClient"

When I test it from my PC it works.

When I publish it to the (internal) server I can see my user has logged into asp.net but data base access gives me:

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.

Upvotes: 0

Views: 1463

Answers (2)

Martin
Martin

Reputation: 5452

Your connection string is using a "trusted connection" which means the identity of the client process/thread is used in the SQL login attempt. You say that your user has logged in to the ASP.NET app, but what is the identity of the application pool your app runs in?

You don't say what kind of authentication your app uses, but I'm going to assume Windows Authentication. If you want the end-user's account to be used for the SQL login, you will need to enable ASP.NET impersonation for your app. You can do this under "Authentication" in the IIS Manager, or in your web.config with <identity impersonate="true" />

If you don't care which identity is used for the SQL login attempt, you can create a SQL login for your application pool's identity.

Upvotes: 1

C0L.PAN1C
C0L.PAN1C

Reputation: 12243

try to see if SSPI security works

<connectionStrings>
<add name="patbase" connectionString="Data Source=pbsqlserver1;Initial Catalog=patentbase;Integrated Security=SSPI;;Application Name=PatBase Images" providerName="System.Data.SqlClient"/>
</connectionStrings>

or remove the ;;Application Name=PatBase Images at the end if that doesn't work.

Upvotes: 0

Related Questions