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

161 Views Asked by At

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 by Get-Package and Get-Help about_EntityFramework.

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

get-migrations in PMC usually lists the migration files that have been implemented since the seed method. I'm particularly confused because "C#" doesn't appear in the command itself...

It looks like someone posted just this question a few days ago, but the author removed it.

Any ideas as to what might be causing this?

--

EDIT: Here are the packages in the codebase, as reported by Get-Package (with ProjectName column removed):

Id                                  Versions                                                                --------                                 -----------                                   
Antlr                               {3.5.0.2}   
bootstrap                           {4.6.0}    
EntityFramework                     {6.4.4}    
jQuery                              {3.6.0}     
jQuery.Validation                   {1.19.3}     
Microsoft.AspNet.Mvc                {5.2.7}  
Microsoft.AspNet.Razor              {3.2.7}   
Microsoft.AspNet.Web.Optimization   {1.1.3}    
Microsoft.AspNet.WebPages           {3.2.7}   
Microsoft.CodeDom.Providers.DotN... {3.6.0}    
Microsoft.jQuery.Unobtrusive.Val... {3.2.12}   
Microsoft.Web.Infrastructure        {1.0.0.0}  
Modernizr                           {2.8.3}    
Newtonsoft.Json                     {13.0.1}  
popper.js                           {1.16.1}    
System.Reflection                   {4.3.0}   
WebGrease                           {1.6.0}    
Microsoft.AspNet.Mvc                {5.2.7}   
Microsoft.AspNet.Razor              {3.2.7}    
Microsoft.AspNet.WebPages           {3.2.7}   
Microsoft.CodeDom.Providers.DotN... {3.6.0}    
Microsoft.Web.Infrastructure        {1.0.0.0} 
EntityFramework                     {6.4.4}   
Microsoft.AspNet.Mvc                {5.2.7}    
Microsoft.AspNet.Razor              {3.2.7}  
Microsoft.AspNet.WebPages           {3.2.7}    
Microsoft.CodeDom.Providers.DotN... {3.6.0}   
Microsoft.Web.Infrastructure        {1.0.0.0}  
System.Buffers                      {4.5.1}   
Ical.Net                            {4.2.0}    
MailKit                             {3.4.3}  
Microsoft.CodeDom.Providers.DotN... {3.6.0}   
MimeKit                             {3.4.3} 
NodaTime                            {3.0.9}   
NS.Utilities.EmailHelper            {1.0.23}   
Portable.BouncyCastle               {1.9.0}   
System.Buffers                      {4.5.1} 
System.Diagnostics.EventLog         {7.0.0}    
System.Memory                       {4.5.5}   
System.Numerics.Vectors             {4.5.0}    
System.Runtime.CompilerServices.... {6.0.0}   
System.Security.Principal.Windows   {5.0.0}    
System.Threading.Tasks.Extensions   {4.5.4}   
Antlr                               {3.5.0.2}  
bootstrap                           {4.6.0} 
EntityFramework                     {6.4.4}   
jQuery                              {3.6.0}  
jQuery.UI.Combined                  {1.13.1}  
jQuery.Validation                   {1.19.3} 
Microsoft.AspNet.Mvc                {5.2.7} 
Microsoft.AspNet.Razor              {3.2.7}
Microsoft.AspNet.Web.Optimization   {1.1.3}
Microsoft.AspNet.WebPages           {3.2.7}
Microsoft.CodeDom.Providers.DotN... {3.6.0}
Microsoft.jQuery.Unobtrusive.Val... {3.2.12}
Microsoft.Web.Infrastructure        {1.0.0.0}
Modernizr                           {2.8.3}
Newtonsoft.Json                     {13.0.1}
popper.js                           {1.16.1}
System.Buffers                      {4.5.1}
System.Reflection                   {4.3.0}
WebGrease                           {1.6.0}
2

There are 2 best solutions below

1
user22400064 On

I had to reinstall Visual Studio. Then it worked again.

0
Kev Ritchie On

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.

Hopefully a permanent fix will come for this one soon.