views:

57

answers:

1

I am currently trialing EF4 code-first. My POCO classes inherit from an Audit class that contains CreatedBy, CreatedOn, UpdatedBy, UpdatedOn. I was hoping the framework would include the Audit properties in my Action table when creating my database, however this doesn't appear to be the case. Does anyone know how to enable this without overriding the OnModelCreating() method?

Public Class Audit
    Public Property CreatedOn as DateTime
End Class

Public Class Action
    inherits Audit
    Public Property ActionId As Int32
End Class
+1  A: 

See these links for more information:

http://romiller.com/2010/09/29/ef-ctp4-tips-tricks-code-first-inheritance-mapping/

http://weblogs.asp.net/scottgu/archive/2010/07/23/entity-framework-4-code-first-custom-database-schema-mapping.aspx

http://social.msdn.microsoft.com/Forums/en/adonetefx/thread/bc6f1b05-e58c-4ea3-8565-635614c42d83

Leniel Macaferi
It's a shame properties in a base class need to be explicitly mapped. Especially when you may have 100+ classes that all inherit from the Audit class.
Jamie Carruthers