Visual Studio 2022 Package Manager Console Entity Framework commands return ArgumentNullException
See original GitHub issueThis issue has been moved from a ticket on Developer Community.
[severity:I’m unable to use this version] [regression] [worked-in:16.10] Hello,
I am trying the VS 2022 preview and am encountering an issue when I use the package manager console. I use Entity Framework 6 in my project and commands like Update-Database or Add-Migration all fail with the following error:
System.ArgumentNullException: Value cannot be null. Parameter name: type at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(Type type, Object[] args) at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion) at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebSiteProject(Project project) at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetTargetDir(Project project) at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory) at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges) at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) Value cannot be null. Parameter name: type
When I do those same commands in VS 2019 with the same code, it works without any problem.
Original Comments
Feedback Bot on 8/2/2021, 09:41 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Arthur Vickers [MSFT] on 8/4/2021, 08:18 PM:
I am not able to reproduce this on the latest builds of VS 2022. Can you please make sure you are using the latest version of EF6–that is, version 6.4.4. If it still does not work, then please upload a minimal csproj file that reproduces the issue so that we can further investigate.
Why do we ask for more info?
We try to reproduce all issues reported with the information provided in the description and comments. When we can’t reproduce the issue, we ask you for more information so we can resolve the issue as quickly and efficiently as possible.
In our guidelines, you can get tips on how to provide clear and simple reproducible steps.
Feedback Bot on 8/11/2021, 09:27 AM:
We will close this report in 14 days because we don’t have enough information to investigate further. To keep the problem open, please provide the requested details.
Original Solutions
Feedback Bot solved on 8/26/2021, 09:56 AM, 0 votes:
We are unable to investigate this issue further without the additional information requested. If you are able to provide more information, you can request the issue being reactivate below. See our guidelines for further information about our process.
Tore Aurstad on 11/7/2021, 11:41 AM:
I am able to add migrations with Add-Migration, but using Update-Database freezes Visual Studio 2022 latest preview. If I use earlier Visual Studio version such as 2017 pro or 2019 pro, it works.
Some additional info:
Functionality area: Package Manager Console
DAL : Entity Framework 6.4.4
Problem: EF Code First migrations can be added, but running Update-Database makes VS2022 unresponsive
Standard EF: yes, standard Code First
Affected: Recreated on multiple developer PCs at work
Workarounds: need to switch to VS2017
Please look into EF6 and Package Manager Console in VS2022.
Michael Pose on 11/10/2021, 06:10 PM:
I am experiencing the same issue:
<span class="hljs-selector-tag">PM</span>> <span class="hljs-selector-tag">Update-Database</span>
<span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.ArgumentNullException</span>: <span class="hljs-selector-tag">Value</span> <span class="hljs-selector-tag">cannot</span> <span class="hljs-selector-tag">be</span> <span class="hljs-selector-tag">null</span>.
<span class="hljs-selector-tag">Parameter</span> <span class="hljs-selector-tag">name</span>: <span class="hljs-selector-tag">type</span>
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Activator</span><span class="hljs-selector-class">.CreateInstance</span>(<span class="hljs-selector-tag">Type</span> <span class="hljs-selector-tag">type</span>, <span class="hljs-selector-tag">BindingFlags</span> <span class="hljs-selector-tag">bindingAttr</span>, <span class="hljs-selector-tag">Binder</span> <span class="hljs-selector-tag">binder</span>, <span class="hljs-selector-tag">Object</span><span class="hljs-selector-attr">[]</span> <span class="hljs-selector-tag">args</span>, <span class="hljs-selector-tag">CultureInfo</span> <span class="hljs-selector-tag">culture</span>, <span class="hljs-selector-tag">Object</span><span class="hljs-selector-attr">[]</span> <span class="hljs-selector-tag">activationAttributes</span>)
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Activator</span><span class="hljs-selector-class">.CreateInstance</span>(<span class="hljs-selector-tag">Type</span> <span class="hljs-selector-tag">type</span>, <span class="hljs-selector-tag">Object</span><span class="hljs-selector-attr">[]</span> <span class="hljs-selector-tag">args</span>)
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Data</span><span class="hljs-selector-class">.Entity</span><span class="hljs-selector-class">.Migrations</span><span class="hljs-selector-class">.Extensions</span><span class="hljs-selector-class">.ProjectExtensions</span><span class="hljs-selector-class">.GetProjectTypes</span>(<span class="hljs-selector-tag">Project</span> <span class="hljs-selector-tag">project</span>, <span class="hljs-selector-tag">Int32</span> <span class="hljs-selector-tag">shellVersion</span>)
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Data</span><span class="hljs-selector-class">.Entity</span><span class="hljs-selector-class">.Migrations</span><span class="hljs-selector-class">.Extensions</span><span class="hljs-selector-class">.ProjectExtensions</span><span class="hljs-selector-class">.IsWebSiteProject</span>(<span class="hljs-selector-tag">Project</span> <span class="hljs-selector-tag">project</span>)
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Data</span><span class="hljs-selector-class">.Entity</span><span class="hljs-selector-class">.Migrations</span><span class="hljs-selector-class">.Extensions</span><span class="hljs-selector-class">.ProjectExtensions</span><span class="hljs-selector-class">.GetTargetDir</span>(<span class="hljs-selector-tag">Project</span> <span class="hljs-selector-tag">project</span>)
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Data</span><span class="hljs-selector-class">.Entity</span><span class="hljs-selector-class">.Migrations</span><span class="hljs-selector-class">.MigrationsDomainCommand</span><span class="hljs-selector-class">.GetFacade</span>(<span class="hljs-selector-tag">String</span> <span class="hljs-selector-tag">configurationTypeName</span>, <span class="hljs-selector-tag">Boolean</span> <span class="hljs-selector-tag">useContextWorkingDirectory</span>)
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Data</span><span class="hljs-selector-class">.Entity</span><span class="hljs-selector-class">.Migrations</span><span class="hljs-selector-class">.UpdateDatabaseCommand</span>.<><span class="hljs-selector-tag">c__DisplayClass2</span>.<<span class="hljs-selector-class">.ctor</span>><span class="hljs-selector-tag">b__0</span>()
<span class="hljs-selector-tag">at</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Data</span><span class="hljs-selector-class">.Entity</span><span class="hljs-selector-class">.Migrations</span><span class="hljs-selector-class">.MigrationsDomainCommand</span><span class="hljs-selector-class">.Execute</span>(<span class="hljs-selector-tag">Action</span> <span class="hljs-selector-tag">command</span>)
<span class="hljs-selector-tag">Value</span> <span class="hljs-selector-tag">cannot</span> <span class="hljs-selector-tag">be</span> <span class="hljs-selector-tag">null</span>.
<span class="hljs-selector-tag">Parameter</span> <span class="hljs-selector-tag">name</span>: <span class="hljs-selector-tag">type</span>
<span class="hljs-selector-tag">PM</span>>
Versions:
Microsoft Visual Studio Professional 2022 (64-bit) - Current
Version 17.0.0
NuGet Package Manager - 6.0.0
using Entity Framework 6.2.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:13
- Comments:24 (4 by maintainers)
This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.
We are having the same problem. Updating the version of entity framework is not feasible as it breaks the pipelines. Please provide the existing functionality that work in VS2019