有关实体框架迁移的空参考 [英] Null reference on Entity Framework Migration

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

问题描述

当我使用Entity Framework迁移的Add-Migration命令时,出现以下异常:

When I user the Add-Migration command of Entity Framework migration I get the following exception:

System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetFileName(Project project, String projectItemName) at System.Data.Entity.Migrations.MigrationsCommands..ctor(Object project, Object startUpProject, String configurationTypeName, String connectionStringName, String connectionString, String connectionProviderName, PSCmdlet cmdlet)

System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetFileName(Project project, String projectItemName) at System.Data.Entity.Migrations.MigrationsCommands..ctor(Object project, Object startUpProject, String configurationTypeName, String connectionStringName, String connectionString, String connectionProviderName, PSCmdlet cmdlet)

有见识吗?

推荐答案

在解决方案中有多个项目并且选择了错误"项目作为启动项目之前,我已经看到了这一点.例如,其他人报告说,在Azure托管的MVC3网站中,他们将Azure项目作为启动项目而不是MVC项目.在启动解决问题时切换到MVC项目.

I've seen this before when there are multiple projects in the solution and the "wrong" project is selected as the startup project. For example, somebody else reported that in an Azure hosted MVC3 website they had the Azure project as the startup project instead of the MVC project. Switching over to the MVC project as the startup fixed the issue.

更新:此问题已在EF5-beta2中修复,现在可以在NuGet上使用.

Update: This has been fixed in EF5-beta2, which is now available on NuGet.

这篇关于有关实体框架迁移的空参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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