Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework : Value cannot be null. Parameter name: type

When I execute update-database command, it shows this error message

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"?

like image 943
Nahro Fuad Avatar asked Jan 21 '17 09:01

Nahro Fuad


People also ask

What does value Cannot be null parameter name?

​​​Value cannot be null. Parameter name: InString: This error indicates that an item failed to migrate because it has corrupt MAPI properties. More specifically, Exchange Web Services (EWS) returned a MAPI property whose value should always be a non-empty string, but was returned as an empty string.

How do I update my entity?

The steps to update an existing entity are quite simple. First retrieve an instance of the entity from the EntitySet<T> (in our case ObjectSet<Customer>), then edit the properties of the Entity and finally call SaveChanges() on the context.


1 Answers

For those who do have this problem using Visual Studio 2022: Switch back to Visual Studio 2019, as it doesn't work yet in the 2022 version when you are using an older Entity Framework version.

On the relevant issue file on the Entity Framework 6 GitHub repository, project member ajcvickers commented on 2021-11-18:

[...] EF 6.2 doesn't work. You will need to update to EF 6.4.4. We have so far been unable to reproduce this with EF 6.4.4.

While numerous users have reported upgrading to EF 6.4.4 resolves their problem, the issue is still open, as there are users who can't downgrade to Visual Studio 2019 or upgrade Entity Framework, as those changes could break pipelines.

like image 51
Apfelkuacha Avatar answered Oct 08 '22 05:10

Apfelkuacha