简体   繁体   English

EF 更新数据库错误:值不能是 null 参数名称:类型

[英]EF Update-Database Error: Value cannot be null Parameter name: type

I try to execute command update-database in PMC and always get this error msg.我尝试在 PMC 中执行命令update-database ,但总是收到此错误消息。 I know theres another article basically has the same error but i tried every answer and nothing works.我知道还有另一篇文章基本上有同样的错误,但我尝试了每一个答案,但没有任何效果。

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.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

Value cannot be null.
Parameter name: type

BTW I'm using VS2022 preview.顺便说一句,我正在使用 VS2022 预览版。

Try updating EntityFramework package to the latest version.尝试将 EntityFramework package 更新到最新版本。 I was having the same problem with EF 6.1.3, but then updated to 6.4.4 and it worked fine on VS2022 preview.我在使用 EF 6.1.3 时遇到了同样的问题,但后来更新到 6.4.4,它在 VS2022 预览版上运行良好。

Another way to make it work is to use VS2019.使其工作的另一种方法是使用 VS2019。

When you install Entity Framework 6.3 < you will see the message below:当您安装 Entity Framework 6.3 <时,您将看到以下消息:

A version of Entity Framework older than 6.3 is also installed. The newer tools are running. Use 'EntityFramework\Update-Database' for the older version.

Tooling has been updated and unfortunately Visual Studio 2022 is not compatible with older Entity Framework versions when running commands via Package Manager Console工具已更新,不幸的是,当通过 Package 管理器控制台运行命令时,Visual Studio 2022 与旧版 Entity Framework 不兼容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM