Null reference on Entity Framework Migration(实体框架迁移的空引用)
问题描述
当我使用实体框架迁移的 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.
这篇关于实体框架迁移的空引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:实体框架迁移的空引用


- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01