小编Tha*_*ghe的帖子

Entity Framework Core 2.1 添加迁移 System.NullReferenceException:对象引用未设置到对象的实例

当我们尝试运行 add-migration 时,我们常常会收到以下错误。我们使用 Entity Framework Core 2.1。

System.NullReferenceException:未将对象引用设置为对象的实例。在 Microsoft.EntityFrameworkCore.Metadata.Internal.TableMapping.<>c.b__10_0(IEntityType t) 在 System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable 1 source, Func2 谓词) 在 Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetSortedProperties(TableMapping目标)在 Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Add(TableMapping 目标,DiffContext diffContext)+MoveNext() 在 Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.DiffCollection[T](IEnumerable 1 sources, IEnumerable1 目标,DiffContext diffContext,Func 4 diff, Func3添加,Func 3 remove, Func4[] 谓词)+MoveNext() 在 System.Linq.Enumerable.ConcatIterator 1.MoveNext() at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Sort(IEnumerable1 操作,DiffContext diffContext)在 Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(字符串迁移名称,字符串根命名空间,字符串子命名空间,字符串语言)在 Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(字符串名称,字符串输出目录,字符串 contextType) 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(字符串名称,字符串输出目录,字符串 contextType) 在 Microsoft.EntityFrameworkCore.Design。 Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) 处的 OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0() 未将对象引用设置为对象的实例。

entity-framework-core asp.net-core-2.1

5
推荐指数
1
解决办法
1万
查看次数