当我执行update-database
命令时,它显示此错误消息
System.ArgumentNullException: Value cannot be null.
Parameter name: typeat 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:我有这样的解决方案:
我将启动项目从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/