问题标签 [package-manager-console]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
215 浏览

c# - 无法在 Scaffold-DbContext .Net Core 中将“System.DBNull”类型的对象转换为“System.String”类型

我使用以下方法来使用数据库:

但在某些数据库中,我收到此错误:

无法将“System.DBNull”类型的对象转换为“System.String”类型

此错误发生在Scaffold-DbContext命令写入包管理器控制台后,我按下Enter并没有对任何表进行分类。

我能做些什么来解决这个错误?

在此处输入图像描述

0 投票
1 回答
47 浏览

c# - How can I Update-Database?

this is the code used to generate the migration

dotnet ef migrations add InitialCreate --context DataContext --output-dir Migrations/SqlServerMigrations and this is the DataContext.cs

but when I run Upadate-Database I get the error "More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands."

How can I update the database using this migration?