ConnectionString for ObjectContext in MVC raised Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON' error

245 views Asked by At

I'm working on an MVC application which uses ObjectContext (not DbContext) with EDMX file. As we know ObjectContext connection string is quite different from regular ADO.NET connection string. Here is the connection string I see in the application

<add name="AuthorEntities" connectionString="metadata=res://*/Models.AuthorEntities.csdl|res://*/Models.AuthorEntities.ssdl|res://*/Models.AuthorEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=ServerAddress;database=Author;user id=sa;password=Pass121212;Trusted_Connection=no;Integrated Security=True&quot;" providerName="System.Data.EntityClient" />

This connection string works locally very well but when I deploy the application on production machine. This displays an error:

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

I double checked all my credentials used here but nothing helps. I'm not using any kind of Impersonation settings in config file. By any chance if you faced/know this issue, please help.

1

There are 1 answers

0
moreON On BEST ANSWER

user id=sa;password=Pass121212; ... Integrated Security=True

You are using integrated security (uses current Windows login for authentication) so the username and password here are ignored. You should either change this setting or ensure that your application is running as a user that can access the database.