DataAnnotations in Mvc 6 and Entityframework 7-beta 4

925 Views Asked by At

How to use Dataannotation attributes in mvc 6 with entityframework 7 beta4?

I am not able to use dataannotation attributes such as required, Key,StringLength,MaxLength etc in data model for entityframework code first migration.

I added stringLength(45) in model and getting as nvarchar(max) in table instead of nvarchar(45).

2

There are 2 best solutions below

0
On

In Progress

The following features are currently being implemented. Some scenarios may work, but there are significant limitations as the work is incomplete.

Modeling

Data annotations are attributes that can be added to your entity classes/properties and will influence the EF model (i.e. adding [Required] will let EF know that a property is required).

Source

0
On

DataAnnotations (most) will be available in beta6