C# EF 6-使用2个参数调用SetData时出现错误异常

C# EF 6-使用2个参数调用SetData时出现错误异常,c#,database,entity-framework-6,entity-framework-migrations,C#,Database,Entity Framework 6,Entity Framework Migrations,我有一个多项目的解决方案。DBContext文件和模型位于类库项目中。这个项目有EF 6.1.3,它运行在.NET 4.5.2上。模型和DBContext文件在不同的文件结构中,我的意思是模型在Project/Data/Model中,DBContext在Data文件夹中。此项目似乎已启用到现有数据库的迁移。开发团队过去只是通过构建项目来重新创建数据库。它还有: AutomaticMigrationsEnabled = true; 我正在尝试正确使用迁移,并尝试了以下操作,以确保it Packa

我有一个多项目的解决方案。DBContext文件和模型位于类库项目中。这个项目有EF 6.1.3,它运行在.NET 4.5.2上。模型和DBContext文件在不同的文件结构中,我的意思是模型在Project/Data/Model中,DBContext在Data文件夹中。此项目似乎已启用到现有数据库的迁移。开发团队过去只是通过构建项目来重新创建数据库。它还有:

AutomaticMigrationsEnabled = true;
我正在尝试正确使用迁移,并尝试了以下操作,以确保it PackageManagerConsole能够正确响应

Enable-Migrations
Add-Migration InitialCreate –IgnoreChanges
两者都导致以下错误:

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.
调用带有“2”参数的“SetData”时出现异常:“在程序集“Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject”中键入“Microsoft.VisualStudio.ProjectSystem.VS.Implementation,Version=14.1.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”未标记为可序列化。”位于C:\Users\Temp\.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:718 char:5
+$domain.SetData('project',$project)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:NotSpecified:(:)[],MethodInvocationException
+FullyQualifiedErrorId:SerializationException使用“2”参数调用“SetData”异常:程序集“Microsoft.VisualStudio.ProjectSystem.VS.Implementation,Version=14.1.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”中的类型“Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject”未标记为可序列化。“位于C:\Users\Temp\.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:719 char:5
+$domain.SetData('contextProject',$contextProject)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:NotSpecified:(:)[],MethodInvocationException
+FullyQualifiedErrorId:SerializationException使用“2”参数调用“SetData”异常:程序集“Microsoft.VisualStudio.ProjectSystem.VS.Implementation,Version=14.1.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”中的类型“Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject”未标记为可序列化。“位于C:\Users\Temp\.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:720字符:5
+$domain.SetData('startUpProject',$startUpProject)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo:NotSpecified:(:)[],MethodInvocationException
+FullyQualifiedErrorId:SerializationException System.NullReferenceException:对象引用未设置为对象的实例。位于System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](项目项目,字符串propertyName)的System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(字符串配置类型名称,布尔值useContextWorkingDirectory)的System.Data.Entity.Migrations.EnableMigrationsOptionsCommand.FindContextToEnableSystem.Data.Entity.Migrations.EnableMigrationsCommand.c_uuDisplayClass2.b_u0()处的System.Data.Entity.MigrationsDomainCommand.Execute(Action command)对象引用未设置为对象的实例。

请您查看并告诉我错误的原因。我还尝试将启动项目设置为解决方案中的其他项目。

Hi@alijohn,您是否能够使其正常工作?如果您仍然遇到此问题,可能此其他问题可以帮助您。此解决方案是否可以帮助您