Closed Tzadiko closed 4 years ago
This is most likely due to a LocalDB 2017 bug, update your instance with the latest CU.
This is most likely due to a LocalDB 2017 bug, update your instance with the latest CU.
Brilliant, I updated the CU via the link here: https://support.microsoft.com/en-ie/help/4527377/cumulative-update-18-for-sql-server-2017
(Download link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=56128)
It works now.
After a lot more digging, more on the bug: https://support.microsoft.com/en-ie/help/4096875/fix-access-is-denied-error-when-you-try-to-create-a-database-in-sql-se
Thank you for your reply!
Running the
update-database
command with the-verbose
flag, Entity Framework does not properly construct the path to write the.mdf
file to.As a result it throws an SQL exception:
System.Data.SqlClient.SqlException (0x80131904): CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\Users\TomerNinjaDB.mdf'.
It should be under C:\Users\Tomer\NinjaDB.mdf, or preferably within another nested folder (not sure how to configure this), as such
C:\Users\Tomer\DB\NinjaDB.mdf
Here is an example,
CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\Users\TomerNinjaDB.mdf'.
Steps to reproduce
What steps can we follow to reproduce the issue?
enable-migrations
add-migration
update-database -verbose
NinjaDomain.Classes.csproj
Classes.cs
NinjaContext.cs
Stack Trace
Further technical details
EF Core version: 6.4.0 Database provider: SQLExpress (System.Data.SqlClient) Target framework: 3.1 (e.g. .NET Core 3.0) Operating system: Windows 10 IDE: Visual Studio 2019