entity-framework sql

Why does Entity keep making new databases?

I’m doing a project utilizing Entity Framework’s Code-First approach. Things were going fine, until we changed the location of where the database is created:

connectionString="Data Source=(LocalDB)\ProjectsV12;AttachDbFilename=|DataDirectory|\Schema.Test.mdf;Integrated Security=True;Connect Timeout=30"

And then we set DataDirectory:

AppDomain.CurrentDomain.SetData("DataDirectory", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TestDB\\");

Now, we have several databases with names SCHEMA_TEST_*, where the * is some random number(I’m sure it’s not random, but I hadn’t figured out how it’s generated). Also, I’m not sure what is causing the creation of another database, rather than the first created. Why is it creating the other databases, and why can’t it just be called Schema.Test like I’d mentioned in the connectionString?


When I remove the AttachDbFilename section of the connection string, it all appears to go back to normal no matter what I do. Though, admittedly, I’m still not sure how or why the extra databases are created. Though, it seems to be done every time there’s a change in the schema. Which shouldn’t happen since, we are utilizing migrations.