的EntityFramework启用的迁移的ArgumentException [英] EntityFramework enable-migrations ArgumentException

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

问题描述

我在微软Azure的美丽世界纽比,使我第一次的Hello World网站。下一步是创建一个数据库(的EntityFramework),但我得到一个异常,同时创造从PackageManagerConsole(PMC)数据库。我看了网上一些职位,解释说我需要在startupprojectname添加到PS命令,但可惜的是没有解决我的问题。

I am a newby in the beautiful world of Microsoft Azure and made my first hello world website. The next step is to create a database (entityframework) but I get an exception while creating the database from PackageManagerConsole (PMC). I read a few posts on the web that explained that I need to add the startupprojectname to the PS command, but unfortunatelly that doesn't resolve my problem.

我有2个项目在我的解决方案。

I have 2 projects in my solution.


  • partyonwebsite,这是启动项目,显然我的网站:)

  • 模式在那里我会设计我的模型/实体。

在模式的项目,我有类用户和UsersDb。 UsersDb是从的DbContext继承的类。

In the "models" project I have the classes "User" and "UsersDb". UsersDb is the class that inherits from DbContext.

现在,当我在PMC执行以下命令行:

Now, when I execute the following line in PMC:

enable-migrations -StartUpProjectName "PartyOnWebsite" -ContextTypeName "Models.Users.UsersDb"

我收到以下(不是非常有帮助)错误:

I receive the following (not very helpful) error:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

我看了一下获取帮助实现的迁移和周围有点玩过,但不是很多运气。

I've had a look at get-help enable-migrations and played around a bit but not a lot of luck.

有没有人碰到了同样的问题?或者可以你点我在正确的方向,以帮助我解决呢?

Did anybody bump into the same problem? Or can you point me in the right direction to help me solve it?

非常感谢事先!

巴斯

推荐答案

解决。如果您遇到了同样的问题,确保的EntityFramework是正确设置你的单独的型号的项目。

Solved. If you run into the same problem, make sure that EntityFramework is setup correctly for your seperate "Models" project.


  • 开启管理的NuGet包解决方案。在Solution Explorer(在Solution Explorer中右键点击解决方案)

  • 选择安装包

  • 选择的EntityFramework,然后点击管理

  • 检查你的模型项目(我检查我的两个网站项目和模式项目)

运行您的支持,再次迁移命令。

Run your enable-migrations command again.

我还添加了从我的网站项目模型项目一期工程的参考,我不知道有没有关系。

I also added a project reference from my Website project to the Models project, I don't know if that matters.

这之后我在的NuGet调整命令成功执行:

The command that successfully executed after my adjustments in NuGet:

enable-migrations -ProjectName Models -ContextTypeName Models.Users.UsersDb

希望这有助于回答在他的道路上又输给战士得到他的第一个应用程序在Azure上运行。)

Hope this answer helps another lost soldier in his path to get his first app running in Azure :).

干杯,

巴斯

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆