When declaring a String
property in a Poco class, OrmLite will generate a varchar(8000) NULL
column for it in the database. for e.g. I have the following class and the generated table for it:
I am wondering how can I specify the length for the field. It does not make sense to have 8000 characters for a FirstName for e.g. Also how can I force NOT NULL
? The UserName
and the Password
columns should always have values.
I think you need to look into using annotations: Required
and StringLength
:
[Required]
[StringLength(50)]
So something like:
public class Users {
...
[Required]
[StringLength(50)]
public String UserName { get; set; }
...
}
I think that should do it.
Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With