How to map System.Version as complex type in Entity Framework 6

I have a System.Version object in one of my POCO objects using Code First Entity Framework 6. I would like to map it to a database like:

table Diagnostics
  column ApplicationVersionMajor int
  column ApplicationVersionMinor int
  column ApplicationVersionBuild int
  column ApplicationVersionRevision int

      

How to do it when the class looks something like this:

class Diagnostics 
{
  public System.Version ApplicationVersion { get; set; }
}

      

I know I can decorate my own value objects with the [ComplexType] attribute; I just don't know how to do this for the frame type.

+3


source to share


1 answer


Since System.Version is a class, it can be a complex type. You can mark it as a complex type with a fluid interface.



protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    modelBuilder.ComplexType<System.Version>();
}

      

+2


source







All Articles