When I execute update-database
command, it shows this error message
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"?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With