I can't get Scaffold-DbContext
to work on a EFCore 1.1 application.
PM> Scaffold-DbContext -Connection "'Server=.;Database=testsite;User Id=sa;Password=Password1234;'" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir EFContext -Context ApplicationDbContext
This is the error that it's giving:
Scaffold-DbContext : Cannot bind argument to parameter 'Path' because it is an empty string. At line:1 char:1 + Scaffold-DbContext + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Scaffold-DbContext], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Scaffold-DbContext
Not exactly a forthcoming error message so I ran just Scaffold-DbContext
and it gives me this error after prompting for the Provider. The provider I'm trying to use is Microsoft.EntityFrameworkCore.SqlServer
.
In my case I fixed it installing Microsoft.EntityFrameworkCore.Tools. Make sure to close and reopen VisualStudio. (Do not forget to add the -force flag to the end in order to reapply the changes from scratch) Example:
Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -force
So, my dependencies looks like:
Microsoft.AspNetCore.All
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Tools
After that it worked as expected.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments