EF4 Code First Control Unicode and Decimal Precision Scale with Attrib

added by bunglebooz
12/23/2010 4:27:51 AM

0 Kicks, 187 Views

There are several attributes available when using code first with the Entity Framework 4 CTP5 Code First option. When working with strings you can use [MaxLength(length)] to control the length and [Required] will work on all properties. But there are a few things missing. By default all string will be created using unicode so you will get nvarchar instead of varchar. You can change this using the fluent API or you can create an attribute to make the change. If you have a lot of properties, the attribute will be much easier and require less code.