0

I posted this question on the ASP.NET forums, and was eventually directed to post the same question here.

Original asp.net forums post: http://forums.asp.net/t/1774923.aspx/1?Database+Generated+DateTimes

I'm trying to add CreatedDate and ModifedDate to my Code First models. If this were database first I would have added a GETDATE() default value to both of these. A few options were presented on how to do this using C.F.. However, I think the cleanest suggestion was to use triggers to manage these date fields.

Is there a way to manage the creation of triggers using the E.F./C.F. so that I don't have to re-create them every time my model changes?

ricka6 from the asp.net forums suggested I include the following post as it may be related: Mapping many to many relationship

Thank you! -Walker

Community
  • 1
  • 1
Walker
  • 1
  • 2

1 Answers1

0

Try using EF 4.3 with database migrations, so your database won't be recreated every time your model changes. Alternatively, you can take a look at this question for ideas how to create custom database initializer.

Community
  • 1
  • 1
Balazs Tihanyi
  • 6,659
  • 5
  • 23
  • 24