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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.