1
votes

Entity Framework 6.4 is not properly constructing the filepath it requires to create my .mdf file. For instance, when I run the following command in NuGet PM console:

update-database -Verbose

I get the following error:

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\Users\TomerNinjaDB.mdf'. CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

The file path should be C:\Users\Tomer\NinjaDB.mdf.

Any ideas why this is happening or how to fix it? I pretty much want to tell EF6 where to save these things, because directly under my username isn't too appealing.

1

1 Answers

1
votes

I've found this issue in the official support site for local Db, exactly the same:

https://support.microsoft.com/en-ie/help/4096875/fix-access-is-denied-error-when-you-try-to-create-a-database-in-sql-se

I don't know the version you are using of Sql Server Express, update it could be the solution for that, according to the link.