February 3, 2010 NHibernate
February 3, 2010 NHibernate
I have table CUSTOMER
where CUSTOMER_ID
is primary key.
Table
Mapping
I need to handle assigning of the CustomerID property manually. For
example I created new Customer with CustomerID = 777 and Name
= “Andriy Buday”.
When I call method Session.Save(customer);
I want NHibernate to generate me SQL like this:
Unfortunately I’m getting errors.
Main issue here is that Nhibernate tries to generate ID for me. But I want to save my entity exactly with 777.
Solution
So I need to manually setup my ID property with adding GeneratedBy.Assigned();
Like here:
code
more code
~~~~