Reputation: 5458
I'm working on adding an Entity Framework data context to an ASP.NET 5 class library and I keep getting errors that System.Data.Entity
is not referenced.
Adding a reference to it only works if the build target is set to .net 4.5.1
. This doesn't work for .net core 5
.
I'm using VS 2015 RC and the DNVM version of ASP.NET 5 installed is 1.0.0-beta4
.
Any ideas if this has been moved or why it's not working?
Edit: added the project.json
file
{
"version": "1.0.0-*",
"description": "",
"authors": [ "" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"EntityFramework": "6.1.3",
"Microsoft.DataAnnotations": "1.0.0-beta1"
},
"frameworks": {
"dnx451": { }
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Threading": "4.0.10-beta-22816",
"Microsoft.CSharp": "4.0.0-beta-22816"
}
}
}
}
Upvotes: 2
Views: 895
Reputation: 17424
EntityFramework 6
is not compatible with ASP.Net core 5
, it's why you have this error.
If you want to use EF6
, you must untarget dnxcore50
.
Edit: add sample to untarget 'dnxcore50
Your project.json will be:
{
"version": "1.0.0-*",
"description": "",
"authors": [ "" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"EntityFramework": "6.1.3",
"Microsoft.DataAnnotations": "1.0.0-beta1"
},
"frameworks": {
"dnx451": { }
}
}
}
Or, use EntityFramework 7
Edit: add sample to use EF7
Assuming you want to use SqlServer
and commands to generate migrations, your project.json
will be:
{
"version": "1.0.0-*",
"description": "",
"authors": [ "" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"EntityFramework.Commands": "7.0.0-beta4",
"EntityFramework.SqlServer": "7.0.0-beta4",
"Microsoft.DataAnnotations": "1.0.0-beta1"
},
"commands": {
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { }
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Threading": "4.0.10-beta-22816",
"Microsoft.CSharp": "4.0.0-beta-22816"
}
}
}
}
Upvotes: 2