I kept getting the following exception when I scaffold the entity framework core. I googled and tried multiple suggestions to no avail. Any help is appreciated.
I am using Visual Studio Community 2017. I have installed the Microsoft.EntityFrameworkCore.SqlServer
,
Microsoft.EntityFrameworkCore.SqlServer.Design
and
Microsoft.EntityFrameworkCore.Tools
packages via NuGet
This is the exception:
Exception calling "AddFromFile" with "1" argument(s):
"'basePath' cannot be an empty string ("") or start with the null character.
Parameter name: basePath"
These are the commands I have tried:
Scaffold-DbContext -Connection "Server=1234;UserId=2345;password=3456;Database=4567;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force
Scaffold-DbContext "Data Source=1234;Initial Catalog=4567;User ID=2345;Password=3456" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -force -v
Scaffold-DbContext -Connection "Data Source=1234;UserId=2345;password=3456;Database=4567;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force
I got this error when trying to Scaffold a database with the -OutputDir
value set to a directory that didn't exist. I was hoping it would create the directory but it doesn't. Just make sure your output directory exists and you shouldn't see this error.