I'm using DbUp to migrate my SQL Server database. I've implemented this in a console application, that accepts the connection string. If I run this against my local SQL Server database, it works. If I run it against an Azure SQL database, it works as well.
However, if I run it against a LocalDb database that was created on the fly in my tests, I get an exception.
The line on which the exception occurs is:
EnsureDatabase.For.SqlDatabase(connectionString);
and the connection string parameters contains:
Data Source=(LocalDB)\MSSQLLocalDB;AttachDBFileName=C:\Projects\Prim\mgp\Prim.Mgp.Infrastructure.DataAccessTests\bin\Debug\netcoreapp2.2\Data\ccf243baa63eb4ea258b0155.mdf;Initial Catalog=ccf243baa63eb4ea258b0155;Integrated Security=True;MultipleActiveResultSets=True;
The exception is:
System.Data.SqlClient.SqlException: 'Database 'C:\Users\ludwigs\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\master.mdf' already exists. Choose a different database name. Cannot attach the file 'C:\Projects\Prim\mgp\Prim.Mgp.Infrastructure.DataAccessTests\bin\Debug\netcoreapp2.2\Data\ccf243baa63eb4ea258b0155.mdf' as database 'master'.'
...which is a bit strange, because it mentioning a different database than I specified in the connection string.
Does anyone have a clue what I might be doing wrong?
PS: if I remove the troublesome line of code , I can query my database without problems.