我有一个包含多个项目的解决方案.DBContext文件和Models位于ClassLibrary项目中.这个项目有EF 6.1.3,它运行在.NET 4.5.2上.模型和DBContext文件采用不同的文件结构,我的意思是模型在Project/Data/Model中,而DBContext在Data文件夹中.此项目似乎已启用到现有数据库的迁移.开发团队过去只是通过构建项目来重新创建数据库.它也有:
AutomaticMigrationsEnabled = true;
Run Code Online (Sandbox Code Playgroud)
我正在尝试正确使用迁移,并尝试按照以下方式查看PackageManagerConsole正确反应.
Enable-Migrations
Add-Migration InitialCreate –IgnoreChanges
Run Code Online (Sandbox Code Playgroud)
两者都导致以下错误:
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 : …Run Code Online (Sandbox Code Playgroud)