Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

nhibernate has invalid child element 'add' #618

Unanswered
listentomyblues asked this question in Q&A
Discussion options

I'm having issues running my application where it uses nhibernate. the runtime issue I'm getting is:

The element 'session-factory' in namespace 'urn:nhibernate-configuration-2.2' has invalid child element 'add' in namespace 'urn:nhibernate-configuration-2.2'. List of possible elements expected: 'property, mapping, class-cache, collection-cache, event, listener' in namespace 'urn:nhibernate-configuration-2.2'.

My code is:

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 );
		}

filename contents:

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

I already installed Full-Text and Semantic Extractions for Search but it still didn't fix my issue

You must be logged in to vote

Replies: 1 comment

Comment options

I manage to fix the issue. I changed the <add> in the xml file into <property>

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #615 on September 14, 2023 23:21.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.