如何解决实体框架核心System.ArgumentNullException [英] How to solve entity framework core System.ArgumentNullException

查看:39
本文介绍了如何解决实体框架核心System.ArgumentNullException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从下面的堆栈跟踪中,我无法通过错误消息判断出了什么问题.我用 --verbose 标志运行了迁移命令,希望它有助于查明问题,但 zilch.

From the following stacktrace, I can't tell what is wrong by the error message. I ran the migration command with --verbose flag hoping it would help pinpoint the issue but zilch.

  dotnet ef migrations add migwl3 --verbose

我找不到名为 key

  System.ArgumentNullException: Value cannot be null.
  Parameter name: key
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T   value, String parameterName)
   at     Microsoft.EntityFrameworkCore.SqlServerMetadataExtensions.SqlServer(IKey key)
   at    Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.    <Add>d__41.MoveNext()
   at System.Linq.Enumerable.<CastIterator>d__35`1.MoveNext()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at     Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.   <Add>d__29.MoveNext()
   at     Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.   <DiffCollection>d__56`1.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at      Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.S      ort(IEnumerable`1 operations, DiffContext diffContext)
  at      Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.Scaf      foldMigration(String migrationName, String rootNamespace, String      subNamespace)
   at     Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMig      ration(String name, String outputDir, String contextType)
  at      Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(S    tring name, String outputDir, String contextType)
  at     Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
  at     Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Exec     ute(Action action)
 Value cannot be null.
 Parameter name: key

关于如何将问题归零的任何提示(项目编译良好)将不胜感激

Any tips on how to zero in on the issue (the project compiles fine) would be greatly appreciated

推荐答案

这是搜索 Microsoft.EntityFrameworkCore.Utilities.Check.NotNull 的第一个结果,所以我将添加我的愚蠢的错误:

This is one of the first results from searching for Microsoft.EntityFrameworkCore.Utilities.Check.NotNull, so I'll add my stupid mistake:

我将一个类重构为不同的 DatabaseContext,然后在来自这些不同上下文的两个 IQueryable 查询之间调用 Join——显然你不能在 EntityFramework 中这样做

I refactored a class to a different DatabaseContext, and was then calling Join between two IQueryable queries from those different contexts-- Obviously you can't do that in EntityFramework

这篇关于如何解决实体框架核心System.ArgumentNullException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆