随机查询抛出异常:"Not enough storage is available to complete this operation"

Random queries throw exception: "Not enough storage is available to complete this operation"

我正在开发一个使用 NHibernate(版本 4.0.0.4000)的 MVC 4 项目。目前,我将会话工厂配置为使用位于 C:\Db 目录中的 SQL CE 3.5 文件。

string connString = "Data Source=C:\Db\myDb.sdf; Max Database Size=3096; Persist Security Info=false";

factory = Fluently.Configure()
    //per Sql CE 4.0 usare MsSqlCeConfiguration.MsSqlCe40
    .Database(MsSqlCeConfiguration.Standard.ConnectionString(connString)
        .ShowSql()
        .MaxFetchDepth(3)
        .Driver<MySqlServerCeDriver>())     // FIX truncation 4000 chars
    .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
    .ExposeConfiguration(c =>
    {
        c.SetProperty("cache.provider_class", "NHibernate.Cache.HashtableCacheProvider");
        c.SetProperty("cache.use_query_cache", "true");
        c.SetProperty("command_timeout", "120");
    })
    // FIX BUG per SqlCompact quando si salvano colonne identity
    .ExposeConfiguration(c => c.SetProperty("connection.release_mode", "on_close"))
    .BuildSessionFactory();

我遇到的问题是有时(比如一天一次)我在执行随机查询时遇到以下错误(即使是简单的 select 查询!):

not enough storage space is available to complete this operation

其余时间,一切正常。不用说,我有超过 300GB 的免费空间 space。我进行了搜索,但完全没有发现与我的上下文相关的错误。我开始认为 db .sdf 文件本身有问题:我使用 SQL Server 2008 R2 创建它,但随后使用 "Database .NET 3.5" 执行了一些更改,这是一个非常方便的工具变化。难道是我这样做以某种方式损坏了 .sdf 文件吗?

SQL Server Compact 3.5 不是为 ASP.NET 设计的,也不支持 ASP.NET。这很可能是您收到错误的原因。请改用 SQL Server Compact 4.0 SP1。