2017-08-11 2 views
1
public void Initialize() 
    { 
     sessionFactory = CreateSessionFactory(); 
    } 

    private ISessionFactory CreateSessionFactory() 
    { 
     return Fluently.Configure() 
      .Database(SQLiteConfiguration.Standard.InMemory().ShowSql()) 
      .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TestMetaData>()) 
      .ExposeConfiguration(cfg => configuration = cfg) 
      .BuildSessionFactory(); 
    } 

    public ISession OpenSession() 
    { 
     ISession session = sessionFactory.OpenSession(); 

     var export = new SchemaExport(configuration); 
     export.Execute(true, true, false, session.Connection, null); 

     return session; 
    } 

この部分はエラーSystem.Data.SQLite.SQLiteException生成している:SQL論理エラーが不足していますか「(」近いデータベース:?構文エラーC#流暢SQLLiteインメモリSystem.Data.SQLite.SQLiteException:SQLロジックエラーまたは欠落しているデータベース近い「(」:構文エラー

任意のアイデア

答えて

0

私はこの問題は、あなたの公開設定にスキーマの輸出を適用しているときにあると思うあなたのセッションファクトリを構築する前に、あなたはそれを行う必要があります。 。

sepparatedメソッドOpenSession()を作成して設定していると、誤って適用している可能性があります。

このように、あなたのセッションファクトリの作成は¿

private ISessionFactory CreateSessionFactory() 
{ 
    //the session in which you might want to export your schema 
    ISession session = sessionFactory.OpenSession(); 

    return Fluently.Configure() 
     .Database(SQLiteConfiguration.Standard.InMemory().ShowSql()) 
     .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TestMetaData>()) 
     .ExposeConfiguration(cfg => 
     { 
       //we set the configuration here, and execute it, 
       //before the session factory is built. 
       var export = new SchemaExport(cfg); 
       export.Execute(true, true, false, session.Connection, null); 
     }) 
     .BuildSessionFactory(); 
} 

のようなものである必要があり、あなたはそれを試してみると、問題が解決されたかどうかを確認してくださいもらえますか?

関連する問題