I'm currently attempting to connect to a local copy of a database for testing purposes as to not alter live data.
I'm using MVC with Entity Framework (.Net 4.5), and I'm currently running into this error whenever I attempt to access data through EF:
An exception of type 'System.Data.EntityException' occurred in System.Data.Entity.dll but was not handled in user code
Additional information: The underlying provider failed on Open.
This is the function that is trying to access the data - the error happens on the first line
public IEnumerable<Client> GetClients()
{
List<Client> clients = (from c in this.repository.Clients select c).ToList();
return clients;
}
Here is my connection string in the app.config as well:
<add name="EntitiesConnectionString" connectionString="metadata=res://*/EFName.csdl|res://*/EFName.ssdl|res://*/EFName.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(LocalDb)\v11.0;Initial Catalog=testdb;Integrated Security=True;Pooling=False"" providerName="System.Data.EntityClient" />
I'm using the integrated SQL Server Express that comes with Visual Studio 2015 to manage the local DB that I have created.
More information that I've found:
"Cannot open database \"testdb\" requested by the login. The login failed.\r\nLogin failed for user 'NT AUTHORITY\\SYSTEM'."
I don't believe that I have any permissions set on the db that I created, perhaps something is wrong with the connection string?
Edit:
I've added the 'NT AUTHORITY\NETWORK SERVICE' user, and then added it to the 'db_owner' role in MS SQL Server Management Studio without any luck
I also attempted to create a new login and user with credentials and the 'db_owner' role, and I still receive the same "Login failed for user 'user'."
This is the connection string that I'm using with the test user that I created:
<add name="EntitiesConnectionString" connectionString="metadata=res://*/EFName.csdl|res://*/EFName.ssdl|res://*/EFName.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(LocalDb)\v11.0;Initial Catalog=testdb;Integrated Security=False;Persist Security Info=True;User ID=test;Password=password"" providerName="System.Data.EntityClient" />