iis nhibernate具有无效的子元素“add”

qij5mzcb  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(134)

我在运行使用NHibernate的应用程序时遇到问题。我得到的运行时问题是:
命名空间“urn:nhibernate-configuration-2.2”中的元素“session-factory”在命名空间“urn:nhibernate-configuration-2.2”中具有无效的子元素“add”。预期的可能要素列表:命名空间“urn:nhibernate-configuration-2.2”中的“property,mapping,class-cache,collection-cache,event,listener”。
我的代码是:

protected void Initialization(Assembly[] assemblies, string fileName)
{
    logger.DebugFormat( @"Initialization Start {0:HH:mm:ss.fff}", DateTime.Now );

    SessionFactory = Fluently
        .Configure(
            new Configuration()
                .Configure( fileName )
        )
        .Mappings( x => assemblies
            .ForEach( a => x
                .FluentMappings
                .AddFromAssembly( a )
                .Conventions
                .Add(
                    AutoImport.Never(),
                    DefaultCascade.All(),
                    DefaultLazy.Always(),
                    ForeignKey.EndsWith( "Id" ),
                    PrimaryKey.Name.Is( c => c.EntityType.Name + "Id" ),
                    Table.Is( c => "[" + c.EntityType.Name + "]" )
                )
            )
        )
        .BuildSessionFactory();

    logger.DebugFormat( @"Initialization Finish {0:HH:mm:ss.fff}", DateTime.Now );
}

我已经安装了全文和语义提取搜索,但它没有解决我的问题。
文件名的内容:

<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
        <add name="CoreDbContext" connectionString="Data Source=(localdb)\\mssqllocaldb;Initial Catalog=Database_name;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
        <property name="show_sql">true</property>
        <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    </session-factory>
</hibernate-configuration>
lvjbypge

lvjbypge1#

connectionstring的配置与其他属性类似

<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
        <property name="connection.connection_string">Data Source=(localdb)\\mssqllocaldb;Initial Catalog=Database_name;Integrated Security=True;MultipleActiveResultSets=True</property>
        <property name="show_sql">true</property>
        <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    </session-factory>
</hibernate-configuration>

相关问题