Exception when trying to migrate database in Entity Framework v6.2.0 in Visual Studio v15.8.4

c# database-migration ef-migrations entity-framework entity-framework-6

Question

I set up an Entity Framework database using code first, and whenever I attempt to add a migration or update the database, I get the following error: message of error

PM> update-database
Exception calling "CreateInstance" with "7" argument(s): "Constructor on type 'System.Data.Entity.Migrations.Utilities.DomainDispatcher' not found."
At D:\WTS Projects\ModelCalibration\packages\EntityFramework.6.2.0\tools\EntityFramework.psm1:783 char:5
+     $dispatcher = $utilityAssembly.CreateInstance(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : MissingMethodException

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Migrations.MigrationsDomainCommand.WriteLine(String message)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object reference not set to an instance of an object.

The database migration went without a hitch once I transferred the project to a different machine running the identical versions of Visual Studio, Entity Framework, and Windows. I also downloaded the example project on these two computers (docs) and received the same problem on this one but not on the other, therefore I don't think it has anything to do with my code.

The only fix I could discover was on this topic, here, and it included reinstalling Windows, which I don't really want to do.

Additionally, I have done everything suggested in related SO postings like When I attempt to activate migrations in EF 4.3.1, an exception is generated., which instructed how to fix Visual Studio and reinstall Entity Framework, among other things.

I'm using Windows 10, the.NET Framework 4.6.1, Visual Studio 15.8.4, and the Entity Framework 6.2.0.

Had anybody seen this problem previously or has a suggestion for a fix?

Thanks!

1
2
9/25/2018 8:33:42 AM

Accepted Answer

ZZZ_tmp
6
9/20/2018 9:04:25 AM

Popular Answer

Sometimes it's effective to just clean and rebuild your solution.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow