Entities Framework 4 Code First: Inheritance

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

Answers


You can try the ComplexType of Code First, Such as below, I think it is good for OOD

[ComplexType]
public class CreateType
{
    public DateTime CreateOn { get; set; }


    public string CreateBy { get; set; }

    ...
}

public class Action
{
    public int ActionId { get; set; }

    public CreateType CreateType { get; set; }
}

Need Your Help

How to load a script synchronously with RequireJS

javascript asp.net requirejs

I am using RequireJS in ASP.NET. There is a user control that includes a script file, and registers a startup script in order to initialize itself. Here's the generated code:

Mysql LOAD LOCAL DATA INFILE - Chinese characters issue

bash character-encoding mysql

I'm trying to load an UTF8 CSV file with Chinese characters on it, only to discover that in my table the correct encoding is lost. My table has UTF8 as configured charset.