entity-framework - Entity Framework : Value cannot be null. 参数名称:类型

标签 entity-framework types null

当我执行update-database命令时,它显示此错误消息

System.ArgumentNullException: Value cannot be null.
Parameter name: type

at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebSiteProject(Project project)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetTargetDir(Project project)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

Value cannot be null.
Parameter name: type"?

最佳答案

解决方案:对我来说,解决方案就像重新启动Visual Studio一样容易。

Senario:我有这样的解决方案:

solution explorer

我将启动项目从Host更改为包含web.config的UI.Web项目,然后运行update-database命令,但它给了Value cannot be null.异常,直到我重新启动Visual Studio并重新运行update-database命令。这次它表现正常。

关于entity-framework - Entity Framework : Value cannot be null. 参数名称:类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41777590/

相关文章:

python - 有没有办法获取函数参数的类型?

c# - 如果以前的记录在 ItemsSource 集合中没有匹配项,则 WPF ComboBox 绑定(bind)有效,如果有则失败

go - 如何在没有泛型的情况下对这种复合类型层次结构进行建模

c# - LINQ to Entities 无法识别方法 'Int32 ToInt32(Boolean)'

c# - 从现有数据库 EF 5 生成 POCO(满足某些条件)

c# - LINQ to Entities - 查询中的 Where IN 子句

c++ - 为什么 C++ 模板类型匹配不检索引用限定符 '&'?

javascript - JavaScript 中的 null 和 undefined 有什么区别?

java - 空字符串和空字符串的区别

entity-framework - 问题包括查询中的导航属性