我在 MacOS-Terminal 中使用以下命令;
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.
请帮帮我。
答案 0 :(得分:1)
您忘记指定项目名称(如果要将您的迁移存储在与包含您的 DbContext
的项目不同的项目中):
dotnet ef migrations add Student --project YourProjectName
或者如果你在项目目录里面,就不需要指定项目名称:
dotnet ef migrations add Student