-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with database first scaffolding #7068
Comments
Same here when I try to do a Project.json
I also tried with "System.Data.SqlClient": "4.1.0" and "System.Data.SqlClient": "4.1.0.0" Exception
|
I solved the problem, I don't know how, but it's working. Project.json
And I also add this
|
@matjazmav I spent some time debugging this and it is specific to class libraries. You can workaround it by using one of the workarounds listed at the end of https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet. The least intrusive is to add a console application to your project, that references your class library, and then specify it as the startup project. I took your project.json for your class library, and then added a stub console app to the solution with the following project.json; {
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"ClassLibrary1": "1.0.0",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"frameworks": {
"netcoreapp1.1": {
"imports": "dnxcore50"
}
}
} This command then works for me, it successfully scaffolds the model into the class library:
|
I can confirm this as well, as I just ran through the steps that @rowanmiller mentioned. I was using a class library before and created a console app instead to test this. A quick note: @constantin-v project.json includes "System.Data.Common", "System.Data.SqlClient", and "System.Runtime" but those packages are not needed. (May be a side effect of his solution). The following project.json file should resolve this and enable tool commands like 'Scaffold-DbContext' to run:
|
Closing as a dupe of #5320 |
I use this project.json. I think it is enough. I copied some settings from the WebApi project, and it works as well as the WebApi project in my Library project. { "frameworks": { |
I were having the same error. Fixed by making it default project ("Set as Startup Project"). |
I'm having problem with scaffolding
DbContext
. I'm using latest.NET Core 1.1.0 SDK
. I'm following this guide: https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-dbBut when I run following command in Package Manager Console:
Scaffold-DbContext "<connection-string>" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
I get exception.project.json
Exception
The text was updated successfully, but these errors were encountered: