Entity Framework 6、Update-Database -verbose 命令没有构建正确的文件路径来保存我的 mdf 文件

Entity Framework 6, Update-Database -verbose command is not constructing the correct filepath to save my mdf file

Entity Framework 6.4 没有正确构建创建我的 .mdf 文件所需的文件路径。例如,当我 运行 在 NuGet PM 控制台中执行以下命令时:

update-database -Verbose

我收到以下错误:

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.

文件路径应为C:\Users\Tomer\NinjaDB.mdf

知道为什么会发生这种情况或如何解决吗?我非常想告诉 EF6 将这些东西保存在哪里,因为直接在我的用户名下不太吸引人。

我在本地Db的官方支持网站上发现了这个问题,完全一样:

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

我不知道您使用的 Sql Server Express 版本,根据 link.

更新它可能是解决方案