简体   繁体   English

使用 EF 和代码优先方法创建数据库时出错

[英]Error in creating database using EF with a code-first approach

Path is concatenating with database name路径与数据库名称连接

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\\Users\\fahidNinjaDomain.DomainModel.NinjaContext.mdf'. CREATE FILE 在尝试打开或创建物理文件“C:\\Users\\fahidNinjaDomain.DomainModel.NinjaContext.mdf”时遇到操作系统错误 5(访问被拒绝。)。 CREATE DATABASE failed.创建数据库失败。 Some file names listed could not be created.无法创建列出的某些文件名。 Check related errors.检查相关错误。

It should be like this应该是这样的

C:\Users\fahid\NinjaDomain.DomainModel.NinjaContext.mdf

How can I solve this using update-database -verbose ?如何使用update-database -verbose解决此问题?

The missing \\ was caused by a bug from Sql Server.丢失的 \\ 是由 Sql Server 的错误引起的。 See this question for details: CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file .有关详细信息,请参阅此问题: CREATE FILE 遇到操作系统错误 5(Access is denied.) while试图打开或创建物理文件 And download the update here: https://www.microsoft.com/en-us/download/confirmation.aspx?id=56128 .并在此处下载更新: https : //www.microsoft.com/en-us/download/confirmation.aspx?id=56128

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM