So here we are trying to get a handle on EF7 ahead of the game and I'm running into what I can only call madness.
In EF6 I use annotations quite a bit and I am trying to carry that over into EF7 which according to the UnicornStore project this is totally valid, however I'm running into a problem wherein visual studio 2015 complains that I don't have a reference to the System.ComponentModel.DataAnnotations assembly. Fair enough, I add my reference to the assembly and now I get the following from DNX Core 5.0:
Error CS0234 The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) Lib.DNX Core 5.0
For the life of me I can't figure this out as to whats going on here, as when I look at the UnicornStore as my reference there's no reference to that assembly in the project.json, however there is a reference in the project.lock.json and as I understand it you're not supposed to edit that file.
The big question what am I doing wrong? Why would DNX 4.5.x not complain about the reference and yet DNX Core 5.0 is?
The .Net 4.6(also called vNext) web project has a dependency on Microsoft.AspNet.Mvc
. This pulls in a big tree of dependencies, the data annotations are under the package Microsoft.DataAnnotations
for using Data annotation in your project use Microsoft.DataAnnotations
in place of System.ComponantModel.DataAnnotations
.
I just had precisely this problem with beta8. I resolved it by combining the other answers and comments given here so as to provide cross-compilation for both DNX 4.5.1 and DNX Core 5.0:
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.ComponentModel.DataAnnotations": "4.0.0.0"
},
"dependencies": {
}
},
"dnxcore50": {
"dependencies": {
"System.ComponentModel.Annotations": "4.0.11-beta-23409"
}
}
}