I am trying to create data model from the existing database by executing Scaffold-DbContext command at Package Manager Console by using this command:
Scaffold-DbContext "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\*****\Books.mdf;Integrated Security=True;Connect Timeout=30" "Microsoft.EntityFrameworkCore.SqlServer" -o Models
However, I get this error message which doesn't make sense to me since I point to the exact location where this .mdf file resides (I've searched the possible solutions to this error message). What else could be wrong?
The settings: Win10, VS2019, C#, Project: Console App (.NET Framework) and Console Application (I've tried both). NuGet packages installed: Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.Design, Microsoft.EntityFrameworkCore.Tools
The complete output:
> PM> Scaffold-DbContext "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\*****\Books.mdf;Integrated Security=True;Connect Timeout=30" "Microsoft.EntityFrameworkCore.SqlServer" -o Models
> Build started...
> Build succeeded.
>Microsoft.Data.SqlClient.SqlException (0x80131904):
An attempt to attach an auto-named database for file D:\*****\Books.mdf failed.
A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
ClientConnectionId:a64a8f06-79ad-4c0c-a08a-e45182b5787c
Error Number:15350,State:1,Class:14
An attempt to attach an auto-named database for file D:\*****\Books.mdf failed.
A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
PM>