简体   繁体   中英

Using ServiceStack.OrmLite how can I add a bool column with a default value?

I'm using C# and the latest version of ServiceStack.OrmLite (4.0.33) and I'm trying to add a column of type bool to an existing table with existing data. I get the obvious error that I cannot add a column to an existing table because of null values and the new column does not have a default value. Looking at the Default attribute I don't see where I can set the default value to be false . I don't want the column to allow nulls. I can't imagine this hasn't been done before.

As always, any help is greatly appreciated.

On ServiceStack 4.0.36 with Azure SQL server I was able to use:

  [Default(typeof(bool), "0")]

For the "false" default value on a boolean (bit) field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM