I am running into what I think are two related problems.
I want to create a localdb database for an ASP.NET project in a user-defined location. I do not want the database files put under C:\Users\Mark (for one thing, it's an SSD; for another, I'd never think to look there).
This turns out to be unbelievably, amazingly difficult to do. Which it shouldn't be. Note to MS: it's my computer, >>I<< decide where the files I create go, not you.
I can create databases using migrations and update-database. But they always show up under C:\Users\Mark. If I try to move them where I want them, and specify a full path location in the connection string, I get a "login failed for user Mark".
Which is a ridiculously, amazingly unhelpful error message, and the cause of truly astounding amounts of frustration among developers (note to MS: please, someday, make it a priority to include useful error messages in your products).
One other thing: in the course of experimenting, I deleted the database files from an earlier test. That now seems to be keeping me from creating a new database with the same name, even under C:\Users\Mark. I get the same "login failed" message.
But if I change the name of the connection string in appconfig to something new (e.g., Council2015 -> Council2015xyz), a database will be created under C:\Users\Mark when I run update-database. It's as if something somewhere is remembering the old databases
and refusing to let me use the names over again. How do I clear that out?
It also seems like the >>name<< of the connection string is what's used to name the database, regardless of the connection string also specifying Initial Catalog or AttachDBFile. That doesn't appear to be documented anywhere, but then again,
half the stuff MS releases these days isn't documented. So now that I think about it I wouldn't mind a link to a good discussion of just what goes into an EF6 code first connection string and how the parameters get used.
Here's the connection string I'm using in appconfig:
<add name="Council2015" connectionString="Data Source=(LocalDb)\\v11.0;Integrated Security=True;AttachDbFilename=E:\\Programming\\Council2015\\Council2015\\App_Data\\Council2015.mdf;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient"/>
- Mark