问题描述
当我使用实体框架迁移的 Add-Migration 命令时,出现以下异常:
When I user the Add-Migration command of Entity Framework migration I get the following exception:
System.NullReferenceException:对象引用未设置为对象的实例.在 System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetFileName(项目项目,字符串 projectItemName)在 System.Data.Entity.Migrations.MigrationsCommands..ctor(对象项目,对象 startUpProject,字符串 configurationTypeName,字符串 connectionStringName,字符串 connectionString,字符串 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.
这篇关于实体框架迁移的空引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!