这个报错是说有多个DbContext。
最后检查是发现自己在program中注册DbContext方式错误:
services.AddDbContext(options => options.UseMySql(connectionString, new MySqlServerVersion(new Version(“8.0.23”))));
这样子,除了自己编写的MysqlDbContext,程序还会生成一成另一个DbContext。所以有两个。
正确应该是:
services.AddDbContext(options =>
{
options.UseMySql(connectionString, new MySqlServerVersion(new Version(“8.0.23”)));
});
More than one DbContext was found. Specify which one to use. Use the ‘-Context‘ parameter for PowerS
最新推荐文章于 2024-10-17 14:36:54 发布