0

我想使用火鸟 2.5。在 .NET 4.0 项目中嵌入 NHibernate 3.2。使用 firebird 提供者的代码,这项工作非常棒。但是当我尝试配置 NHibernate

Configuration = new Configuration().Configure();

升级版:

当我尝试建立会话工厂时

Factory = Configuration.BuildSessionFactory();

发生错误:

文件“C:\MYDB.FBD”的“CreateFile (open)”操作期间的 I/O 错误尝试打开文件时出错

在 app.config 中一切看起来都很好

    <configSections>
    <section
        name="hibernate-configuration"
        type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"
    />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
            <property name="connection.driver_class">NHibernate.Driver.FirebirdClientDriver</property>
            <property name="connection.connection_string">
                Server=localhost;
                ServerType=1;
                Database=C:\MYDB.FBD;
                User=SYSDBA;Password=masterkey
            </property>
            <property name="show_sql">true</property>
            <property name="dialect">NHibernate.Dialect.FirebirdDialect</property>
            <property name="command_timeout">60</property>
            <property name="query.substitutions">true 1, false 0, yes 1, no 0</property>
    </session-factory>
</hibernate-configuration>
<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>

4

2 回答 2

0

我的猜测是,firebird 嵌入式使用该文件exclusivly,当您打开另一个会话时,它会尝试连接到同一个文件并抛出。

以下其中一项有帮助:

  • 保持全球联系并做OpenSession(globalConnection);
  • 实现 IConnectionProvider 以分发单个数据库连接
于 2012-02-14T11:25:13.663 回答
0

因为我没有看到解决方案,所以我会添加我发现的内容 - 尽管这篇文章有多老:你必须FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabase(ConnectionString);在使用数据库之前调用。

https://sourceforge.net/p/firebird/mailman/message/9316804/

问候 Juy Juka

于 2017-02-27T12:18:27.547 回答