jeudi 11 juin 2015

How to map SQLite column of type 'BOOL' using EF6?

I am working with an SQLite database and am having some trouble mapping BOOL columns using EF6. The following code essentially works, except for the Active property.

[Table(Name="Test")]
public class Test
{    
    [Key]
    [Column(Name = "TestId", IsDbGenerated=true)]
    public int TestId { get; set; }

    [Column(Name = "TestX")]
    public string TestX { get; set; }

    [Column(Name = "TestY")]
    public string TestY { get; set; }

    [Column(Name = "Active", DbType = "Bit")]
    public bool Active { get; set; }
}

This is the table definition:

CREATE TABLE Test
(
    TestId  INTEGER PRIMARY KEY AUTOINCREMENT,
    TestX   VARCHAR NOT NULL,
    TestY   VARCHAR NOT NULL,
    Active  BOOL NOT NULL DEFAULT true
)

I figured it has something to do with DbType. Omitting it doesn't work and neither does value Boolean.

Aucun commentaire:

Enregistrer un commentaire