SQL CE 和 StructureMap
我正在使用 Entity Framework CF、StructureMap 和 SQL CE 开发 ASP.NET MVC 3 应用程序。 代码如下:
Repository
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(string connectionString) : base(connectionString)
{
}
public DbSet<Foo> Foo { get; set; }
}
public class FooRepository : IFooRepository
{
private readonly ApplicationDbContext db;
public FooRepository(ApplicationDbContext db)
{
this.db = db;
}
public List<Foo> GetAll()
{
return db.Foo.ToList();
}
}
StructureMap config
For<ApplicationDbContext>()
.HybridHttpOrThreadLocalScoped()
.Use<ApplicationDbContext>()
.Ctor<string>("connectionString")
.EqualToAppSetting("DbConnectionString");
For<IFooRepository>().Use<FooRepository>();
一切正常,但一旦应用程序变得不活动,我会在 10-15 分钟后调用 IFooRepository.GetAll()
,我得到以下异常:
System.Data.SqlServerCe.SqlCeException:
Internal error: Unable to successfully execute disk IO on the file system.
任何帮助将不胜感激!
I'm developing an ASP.NET MVC 3 application using Entity Framework CF, StructureMap and SQL CE.
Here's the code:
Repository
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(string connectionString) : base(connectionString)
{
}
public DbSet<Foo> Foo { get; set; }
}
public class FooRepository : IFooRepository
{
private readonly ApplicationDbContext db;
public FooRepository(ApplicationDbContext db)
{
this.db = db;
}
public List<Foo> GetAll()
{
return db.Foo.ToList();
}
}
StructureMap config
For<ApplicationDbContext>()
.HybridHttpOrThreadLocalScoped()
.Use<ApplicationDbContext>()
.Ctor<string>("connectionString")
.EqualToAppSetting("DbConnectionString");
For<IFooRepository>().Use<FooRepository>();
Everything works fine, but once application becomes inactive and I call IFooRepository.GetAll()
after 10-15 minutes, I get the following exception:
System.Data.SqlServerCe.SqlCeException:
Internal error: Unable to successfully execute disk IO on the file system.
Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论