c# - Fluent NHibernate Generated AND Assigned ID Columns -


i'm using fluent nhibernate data-persistence in web application.

my problem... have base class maps entities id property of type t (almost int or guid) using generatedby().identity()

on application start-up, have boot-strapper checks , verifies needed seed-data populated. problem is, of seed-data populated needs specific id. (ids correspond enum or system user)

is there way force nhibernate commit record using id i specify, rather auto-generated one? other commits repository thereafter can auto-generated.

id(x => x.id).generatedby.assigned(); 

if want application assign identifiers (as opposed having nhibernate generate them), may use assigned generator. special generator use identifier value assigned object's identifier property. careful when using feature assign keys business meaning (almost terrible design decision).

due inherent nature, entities use generator cannot saved via isession's saveorupdate() method. instead have explicitly specify nhibernate if object should saved or updated calling either save() or update() method of isession.

http://nhibernate.info/doc/nhibernate-reference/mapping.html#mapping-declaration-id-assigned


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -