views:

15

answers:

1

I'd like to save the creation time of a row, so I have created a datetime column and set it's Default Value to be Getdate(). But when I generate the dbml file from SQLMetal and re-create the database from it, the function is missing.

I've added the /functions parameter to the command line when running SQLMetal but this didn't fix the problem.

Alternatively is there any other way to save the row creation time, that can be reverse engineered by SQLMetal?

A: 

I found a way to solve this by creating a trigger to update the column after an INSERT. However SQLMetal does not extract triggers either, so I've used method hiding to overload the CreateDatabase() method of the DataContext, and add the trigger manual after calling the base method.

Not an ideal solution as there's no compiler checking of the errors in the SQL of the trigger, but I'll create a unit test to check it automatically.

J_men