EF5:无法附加文件“{0}"作为数据库“{1}" [英] EF5: Cannot attach the file ‘{0}' as database '{1}'

查看:36
本文介绍了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.

  1. 在开始/程序菜单下打开VisualStudio 开发人员命令提示符".
  2. 运行以下命令:

  1. Open the "Developer Command Propmpt for VisualStudio" under your start/programs menu.
  2. Run the following commands:

sqllocaldb.exe 停止 v11.0

sqllocaldb.exe 删除 v11.0

这篇关于EF5:无法附加文件“{0}"作为数据库“{1}"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆