I use the following method to use Databases:
Scaffold-DbContext "Server=[serverName] ; Database=[DatabaseName]; user id= [UserId] ; password = [Password];"
Microsoft.EntityFrameworkCore.SqlServer
-Project "[ProjectName]" -Force
-ContextDir "[DirectoryNameOutPut]\Context"
-OutputDir "[DirectoryNameOutPut]"
-UseDatabaseNames -NoPluralize
But in some databases, I get this error:
Unable to cast object of type 'System.DBNull' to type 'System.String'
This error occurs after the Scaffold-DbContext
command is written in the Package Manager Console and I press Enter and does not classify any of the tables.
What can I do to fix this error?
Add -Verbose
flag to your Scaffold-DbContext
to get more details.
Scaffold-DbContext "Server=[serverName] ; Database=[DatabaseName]; user id= [UserId] ; password = [Password];"
Microsoft.EntityFrameworkCore.SqlServer
-Project "[ProjectName]" -Force
-ContextDir "[DirectoryNameOutPut]\Context"
-OutputDir "[DirectoryNameOutPut]"
-UseDatabaseNames -NoPluralize
-Verbose