我在VS 2012 RTM上,使用EF 5.我正在执行Code First,但是因为我刚刚开发,所以试图忽略代码迁移.为了避免它们,我有这套
Database.Setinitializer(new DropCreateDatabaseIfModelChanges<SomeContext>());
偶尔,即使我不认为我触及了模型,它也决定重新创建.没关系.但它通常会导致错误
Cannot drop database because it is currently in use.
所以我决定完全删除数据库.我进入VS,转到“sql Server对象资源管理器”,找到数据库并删除它.现在我被困住了
Cannot attach the file ‘{0}’ as database ‘{1}’
我昨晚发生这种情况,我只是摆弄它直到它工作(关闭任务,重新启动VS,更改web.config中的数据库和文件名等.
所以问题1)我如何摆脱这种状态?
但更重要的问题是,我如何防止自己进入这种状态呢?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。