'Mappings ConfigurationProperties'不包含'FluentMappings'的定义

时间:2017-08-03 19:54:22

标签: c# sql-server nhibernate fluent-nhibernate

我正在使用Fluent NHibernate配置我的数据库。这就是我在createSessionFactory方法中所拥有的。

private static ISessionFactory CreateSessionFactory()
{
    return Fluently.Configure()
        .Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2012
        .ConnectionString(c => c
        .FromConnectionStringWithKey("connectionStringKey"))
        .Mappings(m =>
            m.FluentMappings.AddFromAssemblyOf<Program>())
        .ExposeConfiguration(BuildSchema)
        .BuildSessionFactory());
}

我在fluentMappings下收到错误,它说:

  

Mappings ConfigurationProperties不包含FluentMappings的定义

1 个答案:

答案 0 :(得分:1)

You are missing a parenthesis

private static ISessionFactory CreateSessionFactory()
{
    return Fluently.Configure()
        .Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2012
            .ConnectionString(c => c.FromConnectionStringWithKey("connectionStringKey")))
        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
        .ExposeConfiguration(BuildSchema)
        .BuildSessionFactory();
}