0

I am trying to create a DB from EF Core migration. With this connection string.

"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=BookList_RazorDemo;Trusted_Connection=True;MultipleActiveResultSets=True"

}

The add-migration command on the PMC works fine, but when I execute update-database it give me an error saying that it cannot open or create the physical file 'C:\Users\[User]BookList_RazorDemo.mdf', the users name and the mdf file name are not separated by .

Is there a parameter I can specify with the update-database command to set my output path for the mdf file, or where can I set the output directory otherwise?

Thank you in advance.

2 Answers 2

1

You can specify the path to your .mdf file by adding AttachDbFileName to the connection string (Documentation):

Server=(LocalDB)\\MSSQLLocalDB;Integrated Security=true;AttachDbFileName=D:\Data\MyDB1.mdf

Sign up to request clarification or add additional context in comments.

1 Comment

Nice, it works. Last time I was using EF Core it didn't recognise AttachDbFIleName as property.
0

This is Fixed in latest SQL Server 2017 CU!

https://github.com/dotnet/ef6/issues/384#issuecomment-398313650

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.