启用迁移安装错误

启用迁移安装错误

本文介绍了启用迁移安装错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个项目中启用迁移时遇到问题。
我从Nuget控制台执行 启用迁移 命令,并收到一条错误:

I'm running into a problem when enabling migrations on one of my projects.I execute Enable-Migrations command from the Nuget Console and receive an error saying:

Exception calling "SetData" with "2" argument(s): "Type
'Microsoft.VisualStudio.TeamArchitect.ModelingProject.ModelProjectAutomationObject' in assembly
'Microsoft.VisualStudio.TeamArchitect.ModelingProject, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable."
At D:\Solution\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:391 char:5
+     $domain.SetData('startUpProject', $startUpProject)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SerializationException


$ b $有人在面对这个问题之前,可以指出我的方向正确。

环境:

.NET 4.5

实体框架5

Visual Studio 2012更新2

Has anyone faced this problem before that can point me in the right direction.

Environment:
.NET 4.5
Entity Framework 5
Visual Studio 2012 Update 2

推荐答案

发现问题!

问题是我的解决方案中的启动项目是建模项目。
由于某些原因,在我的项目中启用迁移时,该模块将查看与启动项目相关的库。

Found the problem!
The issue was that the startup project in my solution was a modeling project.For some reason when enabling migrations on my project, the module looks at libraries related to the startup project.

将我的启动项目更改为测试项目解决方案和一切工作。

Changed my startup project to be a test project in the solution and everything worked.

更新

确保您的启动项目包含要用于连接到数据库的 app.config web.config 文件。即使您的 DbContext 位于不同的项目中,它也将用于生成迁移的文件。您可以将包含您的 DbContext 的项目设置为启动项目。

Make sure your startup project contains the app.config or web.config file you want to use to connect to database. This is the file that it will be used to generate migrations even if your DbContext is located on a different project. You can set the project containing your DbContext as the startup project.

这篇关于启用迁移安装错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 18:30