EF5: Cannot attach the file ‘{0}#39; as database #39;{1}#39;(EF5:无法附加文件“{0}作为数据库“{1})
问题描述
我遇到了上述的确切问题 这里(阅读无法附加到已删除的MDF文件"部分),但那里没有告诉问题的解决方案...
I'm encountering the exact issue as described here (read section "Cannot Attach to Deleted MDF File"), but the solution to the problem is not told there...
简而言之,问题是删除 .mdf
文件后,当我尝试使用 EF 5.0 访问数据库时抛出以下异常.
In short the issue is that after deleting the .mdf
file, the following exception is thrown when I try to access the DB using EF 5.0.
DataException->EntityException->SqlException:
无法附加文件{0}"作为数据库{1}"
DataException->EntityException->SqlException:
Cannot attach the file ‘{0}' as database '{1}'
我确实删除了 DB 文件,现在我在运行应用程序时收到了令人讨厌的错误消息,希望它使用它的初始化程序.有什么办法可以解决这个问题?
I did delete the DB file and now I get that nasty error message when running the application expecting it to use it's initializer. Any way to fix this?
推荐答案
如果删除 DB 文件,它仍会在 SqlLocalDB 中保持注册状态.有时它会修复它以删除数据库.您可以从命令行执行此操作.
If you delete the DB file, it still stays registered with SqlLocalDB. Sometimes it fixes it to delete the DB. You can do this from the command line.
- 在开始/程序菜单下打开VisualStudio 开发人员命令提示符".
运行以下命令:
- Open the "Developer Command Propmpt for VisualStudio" under your start/programs menu.
Run the following commands:
sqllocaldb.exe 停止 v11.0
sqllocaldb.exe 删除 v11.0
这篇关于EF5:无法附加文件“{0}"作为数据库“{1}"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:EF5:无法附加文件“{0}"作为数据库“{1}"


基础教程推荐
- oracle区分大小写的原因? 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01