How do I configure NHibernate to create the db schema with a column like this:
create_dt datetime not null default getdate()
I have this in the mapping file:
<property name="create_dt" update="false" insert="false" generated="insert" not-null="true" />
Is there anyway I can inject the sql server specific default getdate()
. The documentation for generated properties even mentions this is how you handle a create_date field. I'm just not sure how to make my db schema generate properly. Will I have to edit the create table scripts manually?
Similar question.
EDIT: I figured out I can always change the table schema like so:
<database-object>
<create>ALTER TABLE Report ADD CONSTRAINT DF_report_create_dt DEFAULT getdate() FOR create_dt;</create>
<drop></drop>
</database-object>
and I could add a trigger in the same way for an update_dt type of field. This seems better than supplying explicit insert and update statements that use getdate().