Enterprise Framework

Software Solutions in the Enterprise

Error : Entity Framework : Update-Database

Error : Entity Framework : Update-Database

PM> Update-Database -ConnectionString "data source=.;Integrated Security=true;initial catalog=my_db" -ConnectionProviderName "System.Data.SqlClient" -Verbose

Using StartUp project 'Integration Services Project1'.

Using NuGet project 'MyDataProject'.

Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.DataWarehouse.VsIntegration.Shell.Project.Extensibility.ProjectExt' in assembly 'Microsoft.DataWarehouse.VsIntegration, 

Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' is not marked as serializable."

At C:\Source\Repos\MyApplication\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:720 char:5

+     $domain.SetData('startUpProject', $startUpProject)

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : SerializationException

 System.NullReferenceException: Object reference not set to an instance of an object.

   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion)

   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebProject(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)

Object reference not set to an instance of an object.


How to fix:

  1. In Package Manager Console, make sure "Default Project" is set to the project that has Data Migrations enabled
  2. Make sure the Web Project is set as the Start project (I know crazy)
  3. Make sure the database connection string is correct.



Comments are closed