Cannot attach the file ‘{0}' as database '{1}'

EF使用CodeFirst,当使用localDB时,删除mdf文件,会报“Cannot attach the file ‘{0}' as database '{1}'”错误。

解决方法如下:

1、打开Visual Studio 命令提示

2、sqllocaldb.exe stop v11.0

3、sqllocaldb.exe delete v11.0

然后重新生成数据库文件即可

posted @ 2016-06-28 23:42  Super丶码农  阅读(242)  评论(0)    收藏  举报