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

查看:184
本文介绍了EF5:无法附加文件“{0}”数据库“{1}”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的具体问题描述<一个href=\"http://odeto$c$c.com/Blogs/scott/archive/2012/08/14/a-troubleshooting-guide-for-entity-framework-connections-amp-migrations.aspx\">here (阅读无法连接到已删除的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...

在短期的问题是,删除密度纤维板文件之后,下面的例外是当我尝试使用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. 在您的开始/程序菜单中打开命令开发为Propmpt的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天全站免登陆