Use structure instead of primitive for property type EF4

I have an EF4 object (first code) that includes an int bit mask. I created a Bitmask framework to make it easier to work with bitmaks (provides bool properties for accessing bits). The bitmask structure includes overloaded implicit operators for converting to and from int.

I tried to set the property type to the bitmask structure, but the value is returned as 0. I know that the value in the database matters, and the bitmask works in my unit tests. I set the HasColumnType parameter to "INT".

Property...

[Required]
[Display(Name = "Display Pages Bitmask")]
[Column(Name = "fDisplayPagesBitmask")]
public DisplayPagesBitmask DisplayPagesBitmask { get; set; }

From the context object ...

protected override void OnModelCreating(ModelBuilder builder)
{
    builder.Entity<Website>()
        .Property(m => m.DisplayPagesBitmask)
        .HasColumnType("INT");
}

Is it possible? If so, what do I need to do to make it work?

+5
2

. int ( ) ( NotMappedAttribute Ignore) , .

+3

struct, , SQLite Entity Framework 6. , ForSQLite, . .

    public Boolean ZystostatikaForSQLite {
        get;
        set;
    }
    public Boolean ImmunsupressivaForSQLite {
        get;
        set;
    }
    public Boolean AntikoagolanzienForSQLite {
        get;
        set;
    }
    public Boolean GlucokortikoideForSQLite {
        get;
        set;
    }
    // 4 Kategorien der Arzneimittel: Zytostatika, Immunsupressiva, Antikoagolanzien, Glucokortikoide
    public struct PharmaceuticalCategories {
        public Boolean Zystostatika;
        public Boolean Immunsupressiva;
        public Boolean Antikoagolanzien;
        public Boolean Glucokortikoide;
    };
    public PharmaceuticalCategories medicineTaken {
        get {
            PharmaceuticalCategories pc = new PharmaceuticalCategories();
            pc.Zystostatika = this.ZystostatikaForSQLite;
            pc.Immunsupressiva = this.ImmunsupressivaForSQLite;
            pc.Antikoagolanzien = this.AntikoagolanzienForSQLite;
            pc.Glucokortikoide = this.GlucokortikoideForSQLite;

            return pc;
        }
        set {
            this.ZystostatikaForSQLite = value.Zystostatika;
            this.ImmunsupressivaForSQLite = value.Immunsupressiva;
            this.AntikoagolanzienForSQLite = value.Antikoagolanzien;
            this.GlucokortikoideForSQLite = value.Glucokortikoide;
        }
    }
0