0

I want to use Firebird 2.5. Embedded with NHibernate 3.2 in .NET 4.0 project. The work is great with firebird provider's code. But when I try to configure NHibernate

Configuration = new Configuration().Configure();

UPD:

when I try to build session factory

Factory = Configuration.BuildSessionFactory();

the error occurs:

I/O error during "CreateFile (open)" operation for file "C:\MYDB.FBD" Error while trying to open file

In the app.config everything looks fine

    <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>

Andrey Ashgaliyev
  • 157
  • 1
  • 4
  • 15

2 Answers2

0

because I didn't see a solution I'll add what I've found - despit how old this post is: You have to call FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabase(ConnectionString); before using the database.

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

Greetings Juy Juka

Juy Juka
  • 189
  • 1
  • 9
0

my guess is that firebird embedded uses the file exclusivly and when you open another session it tries to connect to the same file and throws.

one of the following helps:

  • hold a global connection and do OpenSession(globalConnection);
  • implement IConnectionProvider to handout a single database connection
Firo
  • 30,626
  • 4
  • 55
  • 94