4

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:

enter image description here

enter image description here

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.

Moslem Ben Dhaou
  • 6,897
  • 8
  • 62
  • 93

1 Answers1

9

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.

sgeddes
  • 62,311
  • 6
  • 61
  • 83