Here are the requirements:
- We have a table with a
lastModifiedOncolumn. - We want that column to really, reliably, reflect the (utc) time at which the field was last updated in the database.
- We want that to still be the case when modifying the contents of the tables with Entity Framework.
Right now, we are doing that with a ModificationFunctionMapping/UpdateFunction element in the MSL and a stored procedure defined in the SSDL file.
Is there another way of achieving the same effect, without having to use a Stored Procedure?
EDIT:
In the end, I was not clear enough.
When I said that the “stored procedure [was] defined in the SSDL file”, I meant to say that the stored procedure’s name was defined in the SSDL file – but the problem was that I had to deploy stored procedures with these names on the database, which could conceivably create problems in the event of multiple EF models.
Now that I have understood the use of the <CommandText> element in the SSDL <Function> element, I have been able to put the custom SQL along with the rest of the Entity Framework model – which solved my problem.
You can override the
lastModifiedOncolumn with a trigger insertingcurrent_timestamp. I’m presuming the database server is a Sql Server.