I got a new PC and copied a windows app project I was working on to my new machine. I also copied the associated MDF file over. I dragged the MDF into my solution, I can see it in the Server Explorer, Data Sources, and SQL Server Object Explorer.
As soon as my code tries to access the database, I get the following exception:
Cannot open database \"MyApp.Classes.NorthwindContext\" requested by the login. The login failed.\r\nLogin failed for user 'NEW-PC\Julien'.
The connection string:
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=B:\MyApp\MyApp.Classes.NorthwindContext.mdf;Integrated Security=False"
I have attempted to put my username and password into the connection string to no effect, like so:
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=B:\MyApp\MyApp.Classes.NorthwindContext.mdf;Integrated Security=False;User ID=NEW-PC\Julien;pwd=mypwd"
Some googling says that my login needs to in the Logins
folder of the Security
folder in the SQL Server Object Explorer, which it is.
What do I need to do to allow my code to read this database?