Providing Default value for enum with OrmLite and MySql

I’d like to set a default value for an enum on a poco property to be persisted as string.

Is this supported?

I have this enum:

public enum Language

And this property on a poco:

public Language Language { get; set; }

How can I set the default on the above property to Language.En?

I’ve tried:

[Default(typeof(string), "En")]



Hi @Math,

If you are creating the table with OrmLite, the column for Language by default should be a string type (eg VARCHAR 255). And since En is your first member, it will be the default when not specified without any additional attributes. For example,

public class MyTable
    public int Id { get; set; }
    public Language Language { get; set; }
db.Insert(new MyTable());
// Inserted will be 1, "En"

Visuals from DataGrip:


Are you seeing something else? If so, let us know what versions of ServiceStack and MySql you are using.

Works perfectly.

Seems I was trying to complicate things for nothing…