PMC EF commands error: Unrecognized command or argument 'C#'

Nnr 30 Reputation points
2023-08-16T14:19:06.76+00:00

In Visual Studio's Package Manager Console (V 6.6.0.61), the command

get-migrations, and other Entity Framework commands, output:

Specify --help for a list of available options and commands.

Unrecognized command or argument 'C#'

I have successfully run this and other EF commands through the PMC within the last week. But, seemingly all of a sudden, these commands produce the above two-line output. I have installed EF V6.4.4, verified in PMC by Get-Package and Get-Help about_EntityFramework.

I am using ASP.NET MVC 5, not Core.

Any ideas as to what might be causing this?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,650 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,418 questions
{count} votes

Accepted answer
  1. Piotr Glowala 95 Reputation points
    2023-08-18T09:42:46.3666667+00:00

    I have the same problem - Unrecognized command or argument 'C#' after Add-Migration command.

    Problem on newest VS 2022 (17.7). Problem also starts after update VS2019 to newest version 16.11.29 (before update everything was working great on VS2019).

    Everything works on different machine with VS2019 16.11.27

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Kev Ritchie 11 Reputation points
    2023-08-25T13:30:35.87+00:00

    There is a way to get around this until a fix is released and won't require a reinstall of Visual Studio.

    If you run your commands in Verbose mode from the PMC e.g. Add-Migration "Name of Amendment" --verbose, you will see that for the --language parameter, C# is being output twice.

    You can copy that string out and then remove the second C# from the language parameter, paste it back into the PMC and run it.

    It will then create your migration script. Note, you may need to manually add the migration script to the Migrations folder in your solution via Add->Existing Item and select the 3 files that make up the migration script.

    To update the database, run Update-Database --verbose, copy out the string as above and remove the second C# and then paste back into the PMC and run.

    2 people found this answer helpful.

  2. Mike 0 Reputation points
    2024-02-23T21:41:28.59+00:00

    So did this just never get an answer? Any response at all after the requested info was provided? I've just updated to VS 2022 v17.9.1 and I'm getting this error constantly!

    Microsoft Visual Studio Community 2022
    Version 17.9.1
    VisualStudio.17.Release/17.9.1+34616.47
    Microsoft .NET Framework
    Version 4.8.09032
    Installed Version: Community
    ASP.NET and Web Tools   17.9.195.45391
    ASP.NET and Web Tools
    Azure App Service Tools v3.0.0   17.9.195.45391
    Azure App Service Tools v3.0.0
    Azure Functions and Web Jobs Tools   17.9.195.45391
    Azure Functions and Web Jobs Tools
    C# Tools   4.9.0-3.24081.11+989117396f26e5453ff157df610d22ce45b6b0a9
    C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
    Common Azure Tools   1.10
    Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
    Microsoft JVM Debugger   1.0
    Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
    NuGet Package Manager   6.9.1
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
    Progress Telerik UI for ASP.NET AJAX Extension   2023.2.809.64
    Progress® Telerik® UI for ASP.NET AJAX Extension
    Razor (ASP.NET Core)   17.9.2.2408002+5aec2f1744a2273d3e7157cc4cc1986f87f524d4
    Provides languages services for ASP.NET Core Razor.
    SQL Server Data Tools   17.9.51.1
    Microsoft SQL Server Data Tools
    TypeScript Tools   17.0.30103.2001
    TypeScript Tools for Microsoft Visual Studio
    Visual Basic Tools   4.9.0-3.24081.11+989117396f26e5453ff157df610d22ce45b6b0a9
    Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
    Visual F# Tools   17.9.0-beta.23614.3+a521e1cd420beb56c15faf6836184fadd2b7937a
    Microsoft Visual F# Tools
    Visual Studio IntelliCode   2.2
    AI-assisted development for Visual Studio.
    Visual Studio Tools for Unity   17.9.2.0
    Visual Studio Tools for Unity