【发布时间】:2019-10-23 10:56:13
【问题描述】:
之前,添加迁移对我不起作用,因为迁移和 dbcontext 位于不同的程序集中。在我将它们都移动到同一个程序集中后,该错误不再发生,而是出现了这个新错误。
由于除了堆栈跟踪之外没有太多信息,我无法找到问题所在。
命令:
dotnet-ef migrations add identity
堆栈跟踪:
System.NullReferenceException: 你调用的对象是空的。在 Microsoft.EntityFrameworkCore.Design.Internal.CSharpHelper.Literal(字符串 值)在 Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(CreateTableOperation 操作,IndentedStringBuilder 构建器)在 Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationOperationGenerator.Generate(字符串 builderName、IReadOnlyList1 操作、IndentedStringBuilder 构建器) 在 Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGenerator.GenerateMigration(字符串 migrationNamespace, String migrationName, IReadOnlyList1 upOperations, IReadOnlyList1 downOperations) 在 Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(字符串 migrationName, String rootNamespace, String subNamespace, String 语言)在 Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(字符串 名称,字符串 outputDir,字符串 contextType)在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(字符串 名称,字符串 outputDir,字符串 contextType)在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.c__DisplayClass0_0.<.ctor>b__0() 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.c__DisplayClass3_01.b__0() 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(操作 action) 对象引用未设置为对象的实例。
【问题讨论】:
-
如果我需要发布更多代码,请告诉我,并指定我应该发布什么代码。
-
-
我正在从 VS Code 迁移。
-
您使用的是哪个版本的 EF?
标签: c# asp.net-core entity-framework-core