Search code examples
c#xamarinsqlite.net

How to set default value for Sqlite.net without using sqlite raw statement/conn.execute()


I know it's a stupid question, but I could not find the answer anywhere. How to set a default value for a column in sqlite.net model? Here is my model class:

public class ItemTaxes
{
    [PrimaryKey]
    public string Sku { get; set;}
    public bool IsTaxable { get; set;}// How to set IsTaxable's default value to true?
    public decimal PriceTaxExclusive { get; set;}
}

I wanna set default value of Not Null column IsTaxable to true, how should I achieve that? Btw I do not want use raw sql statement, i.e. conn.execute();

Thank you.


Solution

  • A little late, but for those who got here looking for an answer:

    public class ItemTaxes
    {
        [NotNull, Default(value: true)]
        public bool IsTaxable { get; set; }
    }