I've run into the following situation multiple times:
- prototype a data access layer module using Entity Framework/Code First and LocalDB
- the model changes often and I don't want to polute the module with many migrations; I want to have a clean model generated when I'm sure the model works the way we need; this is why I often delete the generated .MDF file
- After doing this for a few times (maybe 5), I can no longer create a database; the error message says
"System.Data.SqlClient.SqlException occurred
_HResult=-2146232060
_message=An attempt to attach an auto-named database for file {full path to MDF file here} failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
HResult=-2146232060
IsTransient=false
Message=An attempt to attach an auto-named database for file {full path to mdf here} failed. A database with the sa ...
Go to the complete details ...