SQL CE 4.0 - 异常 - 无法删除数据库,因为您没有权限或者它正在被其他进程访问
您好,
我已经在网上完成了一个使用 NuGet 将 SQLCE 4 与 MVC 3 结合使用的示例。
对于大多数用户来说,一切似乎都工作正常,但我时不时地会收到此错误。 无法删除数据库,因为您没有权限或者它正在被其他进程访问。
我实际上无法重现,因为这种情况并不经常发生,我从日志中提取了它。
有人知道我该如何解决这个问题吗?
谢谢
AppStart_SQLECEntityFramework.cs 中的代码
public static class AppStart_SQLCEEntityFramework {
public static void Start() {
Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", HostingEnvironment.MapPath("~/App_Data/"), "");
Database.SetInitializer(new RecreateDatabaseIfModelChanges<OCCardMailout.Domain.OCCardContext>());
}
}
HI,
I have followed through an example on the net of using SQLCE 4 with MVC 3, using NuGet.
Everything seems to working fine for most users, but everynow and again I get this error.
Cannot drop the database, because you do not have permission or it is being accessed by some other process.
I'm not actually able to reproduce as it doesnt happen often, I pulled this from my logs.
Anyone know how I can resolve this?
Thx
The code in the AppStart_SQLECEntityFramework.cs
public static class AppStart_SQLCEEntityFramework {
public static void Start() {
Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", HostingEnvironment.MapPath("~/App_Data/"), "");
Database.SetInitializer(new RecreateDatabaseIfModelChanges<OCCardMailout.Domain.OCCardContext>());
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用 EF4 CodeFirst CTP 吗? SQLCE4 CTP2 中存在一个错误,可能导致 CreateDatabaseOnlyIfNotExist 失败 - 请参阅 http://erikej.blogspot.com/2010/10/sql-server-compact-40-ctp2-released.html
Are you using EF4 CodeFirst CTP ? There is a bug in SQLCE4 CTP2, that can cause CreateDatabaseOnlyIfNotExist to fail - see http://erikej.blogspot.com/2010/10/sql-server-compact-40-ctp2-released.html