.net - dotnet ef 迁移添加引发异常
问题描述
我在 MacOS 终端中使用以下命令;
dotnet ef migrations add Student --project
并得到异常“索引超出了数组的范围。”
User-MacBook-Pro WebAPITutorial % dotnet ef migrations add Student --project
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.ParseOption(Boolean isLongOption, CommandLineApplication command, String[] args, Int32& index, CommandOption& option)
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Index was outside the bounds of the array.
请帮帮我。
解决方案
您忘记指定项目名称(如果要将您的迁移存储在与包含您的项目不同的项目中DbContext
):
dotnet ef migrations add Student --project YourProjectName
或者如果您在项目目录中,则无需指定项目名称:
dotnet ef migrations add Student
推荐阅读
- java - Spring 测试类不读取 application.yml 文件
- sql - 查询以查找具有最大总和的最多行数
- pytorch - 在大图像上训练时pytorch CUDA内存不足
- android - 如何使标题保持在边界线顶部的卡片视图布局?
- node.js - 从自定义命令授予角色
- python - 打开风扇 10 scs 长蟒蛇
- asp.net-core - 在 ASP.Net web api 中使用 IdentityServer3.AccessTokenValidation 与 IDS4 对话
- memory-management - 无法在 Ubuntu 14.04.5 LTS 上安装 pmap
- python - TypeError:“numpy.ndarray”对象不可调用(SciPy 优化)
- ios - 标签栏显示不需要的白色顶部空间