I'm working on a project in MVC 3 (first time using!). One question I keep running into is how to specify datatypes. For example, why have a field of type Nvarchar that has a length of 4000 when you only need a length of 10. As far as I can tell, there is no definitive compilation of specifying server data types for your database. I've been fairly successful so far (Below are some of the ones I've found), and please correct me if I am wrong. My main question is if there is a way to specify a Tinyint (1 byte) in MVC 3.
Here's some of the popular ones I've found:
Smallint
: Specify field as Int16
Bigint
: Specify field as Int64
Nvarchar(n)
: Add [StringLength(n)]
above your variable in your Model
bit
: Seems simple, but for first-time programmers - specify your field as a bool.
DateTime
: There are so many flavors of DateTime, and to specify, initialize your field in your model as DateTime, and specify the type by placing [DataType(DataType.YourPreferredFormat)]
above the variable, where "YourPreferredFormat" is a date/time related option of the enum DataType (DateTime, Date, Time, Duration). I'm not 100% clear on this though, so if anyone knows how each correlates, that would be great to know.