EF 4.x:
EF 4.1+ has a DataAnnotations namespace for the new EF related annotations. Most of them are related to database schema.
EF 5
Not even a DataAnnotations namespace in here. That’s because the annotations got incorporated into .NET 4.5.
.NET 4.5
A new namespace within System.ComponentModel.DataAnnotations: “Schema”
All of the EF schema annotations are in here now. MaxLength and MinLength are in the DataAnnotations namespace.
Added the following thanks to a suggestion from Cecil Phillip
If you are using EF5 with .NET 4, there is a special version of the Entity Framework assembly which actually has the version 4.4.*.
The EF related DataAnnotations *are* in this assembly but notice they’ve been organized into regular and schema as they are in .NET 4.5.
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!
What about EF 5 on .NET 4.0. How will the schema annotations be accessed ?
Ahh good idea Cecil, I modified the post to include that.
Thanks for the fast reply,it seems the VS11 Preview i have has a problem, Uninstall in progress, will download the VS11 Beta, thanks again
Hi, I installed EF 5 on .net 4.0 and the annotation NotMappedAttribute was ignored. Did you also get this problem?
Hi Danimar,
The NotMappedAttribute is part of .NET 4.5. When you combine EF5 with .NET 4, you won’t get the DataAnnotatations.Schema namespace.
Hi, thanks for the reply.
But I used NotMappedAttribute with .Net 4.0. I just updated the EF for version 5, and just this attribute is ignoring.
Maybe still a bug in EF 5.
you’re right. I just did this myself to a .NET 4 project. NotMapped "broke". Turns out that even with the assembly that goes with .NET 4, they moved these into Schema namespace also.
Thank you.
Huge help, was stuck until I found this. Thanks!
Thank you – great help.
Microsoft is just making it up as it goes along. What a pain they are!
Thanks a lot!