Michael Hedgpeth
Michael Hedgpeth

Reputation: 7862

How to map System.Version as Complex Type in Entity Framework 6

I have a System.Version object in one of my POCO entities using a Code First Entity Framework 6 application. I'd like to map it to the database as:

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

How do I do that when the class is something like:

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

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

Upvotes: 3

Views: 641

Answers (1)

bubi
bubi

Reputation: 6501

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

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

Upvotes: 2

Related Questions