Skip to content

If SessionFactoryContext.Flush() takes too long or throws an error

October 19, 2012

If SessionFactoryContext.Flush() takes too long or throws an error like the following: –

Cannot insert the value NULL into column ‘ID’, table ‘database.dbo.table; column does not allow nulls. INSERT fails.
The statement has been terminated.

Or anything along those lines that stops at SessionFactoryContext.Flush() then as I had found out later than sooner that its an issue with nHibernate committing to the database, so its a database structure issue.

It turns out more than likely that you haven’t set an Primary Key to your ID on your database table or an Identity Specification. Remember my blog post on Tuesday where I deliberately switched these off because of a database data import. It turns out i had still left these on, so NHibernate cnnot do any add or update from this! So set PK and Identity Increment on.

 

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: