visual update studio remove migrations framework force first existing enable code automatic c# database entity-framework-6 ef-migrations

c# - update - remove migration entity framework core



EF 6-Excepción de error llamando a SetData con 2 argumento(s) (0)

Tengo una solución con múltiples proyectos. El archivo DBContext y los Modelos están en un proyecto ClassLibrary. Este proyecto tiene EF 6.1.3 y se ejecuta en .NET 4.5.2. Los modelos y los archivos DBContext están en una estructura de archivos diferente, me refiero a que los Modelos están en Proyecto / Datos / Modelo y DBContext está en la carpeta de Datos. Este proyecto parece tener habilitada la migración a una base de datos existente. El equipo de desarrollo solía recrear la base de datos construyendo el proyecto. También tiene:

AutomaticMigrationsEnabled = true;

Intento usar la migración correctamente y he intentado seguir para ver que PackageManagerConsole reaccione correctamente.

Enable-Migrations Add-Migration InitialCreate –IgnoreChanges

Ambos dieron como resultado el siguiente error:

Exception calling "SetData" with "2" argument(s): "Type ''Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject'' in assembly ''Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'' is not marked as serializable." At C:/Users/Temp/.nuget/packages/EntityFramework/6.1.3/tools/EntityFramework.psm1:718 char:5 + $domain.SetData(''project'', $project) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SerializationException Exception calling "SetData" with "2" argument(s): "Type ''Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject'' in assembly ''Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'' is not marked as serializable." At C:/Users/Temp/.nuget/packages/EntityFramework/6.1.3/tools/EntityFramework.psm1:719 char:5 + $domain.SetData(''contextProject'', $contextProject) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SerializationException Exception calling "SetData" with "2" argument(s): "Type ''Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject'' in assembly ''Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'' is not marked as serializable." At C:/Users/Temp/.nuget/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.GetPropertyValue[T](Project project, String propertyName) at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory) at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName) at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) Object reference not set to an instance of an object.

Podría revisar y dejarme saber qué está causando el error. También intenté configurar el proyecto de inicio para otros proyectos en la solución.