1 Replies - 2425 Views - Last Post: 05 October 2011 - 10:38 AM Rate Topic: -----

#1 natbloom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-October 11

C# Winform Fluent NHibernate - getting could not insert exception

Posted 05 October 2011 - 05:29 AM

Hello,

I have a C# Windows Forms application. I am using Fluent NHibernate. I am new to both. I have a MS SQL database with a table (no foriegn keys) with the primary key column as an 'Identity' column. In the Mapping I have tried: Id(x=>x.Id) and Id(x=>x.Id).Generatedby.Identity() and Id(x=>x.Id).Generatedby.Native().
While debugging I can see that the entity is populating fine for a new record with Id=0, but, when I call session.Save(<entity>); it results in System.ApplicationException - Details:could not insert - with table name and it's columns listed and ending with "select SCOPE_IDENTITY()".
I am not sure if it is not able to insert because of identity column or any other issue as there is no further detail in the exception stack trace.

Please help.

Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: C# Winform Fluent NHibernate - getting could not insert exception

#2 wiero  Icon User is offline

  • D.I.C Head

Reputation: 48
  • View blog
  • Posts: 78
  • Joined: 29-June 11

Re: C# Winform Fluent NHibernate - getting could not insert exception

Posted 05 October 2011 - 10:38 AM

hi
what inner exception tells? when i was setting up a code sample to reproduce your error i had an error like yours. the problem was in table and class name, they were different ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1