A few weeks ago I added a column to a SQL table DateCreated. I wanted to track when the records were getting created. I provided a value for the existing columns and then made it not nullable and provided getdate() as its default. I have done this quite often in the past and in the other frameworks I was in it never was a problem.
This time it was. I had made other changes to the database the project used. I updated the edmx file for the data access layer so it would refresh my object model for my code. I did not pay close enough attention to the fact that it now added code to account for the new DateCreated column.
Yesterday we got an error. When looking at the SQL trace I saw that Entity Framework was passing in a '0001-01-01 00:00:00' for the date value because the code giving the values was not providing it a value. I was counting on the app (including the data layer) to not provide a value. The database definition would provide getdate().
Entity Framework did only half the job that needed doing. The presentation layer, or service layer or business layer should have been updated to provide a value if the data layer gets updated with the DateCreated column.
I am glad that we are getting away from using ORM solutions. We are instead relying on lightweight utilities to create a data layer using only ADO.NET. My colleague, Sam started this with LOEF. He is now developing NOEF (No Entity Framwork perhaps with a better name). This will reduce the sleeping dragons we have to deal with.
Mormon Consecration was and is Voluntary
1 week ago