Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
654 views
in Technique[技术] by (71.8m points)

entity framework - Enable-Migrations installation error

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:SolutionpackagesEntityFramework.5.0.0oolsEntityFramework.psm1:391 char:5
+     $domain.SetData('startUpProject', $startUpProject)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SerializationException

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

UPDATE

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...