[英]System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'
[英]Unable to cast object of type 'System.DBNull' to type 'System.String' in Scaffold-DbContext .Net Core
我使用以下方法来使用数据库:
Scaffold-DbContext "Server=[serverName] ; Database=[DatabaseName]; user id= [UserId] ; password = [Password];"
Microsoft.EntityFrameworkCore.SqlServer
-Project "[ProjectName]" -Force
-ContextDir "[DirectoryNameOutPut]\Context"
-OutputDir "[DirectoryNameOutPut]"
-UseDatabaseNames -NoPluralize
但在某些数据库中,我收到此错误:
无法将“System.DBNull”类型的对象转换为“System.String”类型
在包管理器控制台中写入Scaffold-DbContext
命令并且我按Enter并且没有对任何表进行分类后,会发生此错误。
我能做些什么来修复这个错误?
将-Verbose
标志添加到您的Scaffold-DbContext
以获取更多详细信息。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.