Asked by:
Enable-Migrations Parameter is Incorrect in Nuget Console

Question
-
User-939035612 posted
Hi,
I am trying to populate a database with three fields. UserIf, registration date, and last login date. Seems easy enough so I followed a couple of tutorials that told me to create the database table and the columns before adding a new class to my IdentityModels.cs files in my web forms app. Then they say I must enable migrations for it to work because when I try to create a new users I get an error saying "The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269)."
I followed the instructions to enable migrations in Nuget console. Problem is whenever I go to my Nuget console in VS 2019 it says that Enable-Migrations or enable-migrations is an invalid parameter:
Each package is licensed to you by its owner. NuGet is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.
Package Manager Console Host Version 5.1.0.6013
Type 'get-help NuGet' to see all available NuGet commands.
PM> Enable-Migrations
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))Server stack trace:
at EnvDTE.Properties.Item(Object index)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at EnvDTE.Properties.Item(Object index)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
PM> enable-migrations
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))Server stack trace:
at EnvDTE.Properties.Item(Object index)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at EnvDTE.Properties.Item(Object index)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
PM>Can this be solved faster than just adding SQL to the code behind on my registration and login pages?
Thursday, August 22, 2019 8:11 PM
All replies
-
User1520731567 posted
Hi CopBlaster,
CopBlaster
PM> Enable-Migrations
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))Sorry,I can't repeoduce your issue.
Maybe lack of parameters, plz see:
http://msdn.microsoft.com/en-us/data/jj591621.aspx
http://coding.abel.nu/2012/03/ef-migrations-command-reference/
You could also refer to this similar case:
If you still have any questions,please post more details,so that I can reproduce your issue.
Best Regards.
Yuki Tao
Friday, August 23, 2019 9:54 AM -
User-939035612 posted
I found a semi-answer that allowed me to do what I wanted. A YouTube video said to clear all records from the _MigrationHistory table and when I did that I was able to do what I wanted without having to run Enable-Migrations so I guess it must have been enabled already as part of the default webforms template.
Friday, August 23, 2019 6:42 PM