locked
ISSUE! Enable-Migration from Package Manager Console RRS feed

  • Question

  • User-910579361 posted

    Hello

    Can anyone help me out resolving the error iam getting while trying to enable migration to my project. I am working on this tutorial: https://msdn.microsoft.com/da-dk/data/jj193542

    thanks


    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))
    Wednesday, June 17, 2015 8:11 PM

Answers

  • User-271186128 posted

    Hi kkooaa,

    PM> Enable-Migrations

    System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
    

    According to the tutorial, I create a sample on my side (VS2013, EF6, windows 8), it worked well. I sugget you could check the EntityFramework and make sure that EntityFramework is setup correctly for your seperate "Models" project. Here is a similar thread, please refer to it. http://stackoverflow.com/questions/14007169/entityframework-enable-migrations-argumentexception

    The solution which is contains in above link:

    If you run into the same problem, make sure that EntityFramework is setup correctly for your seperate "Models" project.

    • Open "Manage NuGet packages for solution" in solution explorer (right click solution in solution explorer)
    • Select "Installed packages"
    • Select "EntityFramework" and click "Manage"
    • Check your "Models" project (I checked both my website project and the "models" project)

    Run your enable-migrations command again.

    I also added a project reference from my Website project to the Models project, I don't know if that matters.

    The command that successfully executed after my adjustments in NuGet:

    enable-migrations -ProjectName Models -ContextTypeName Models.Users.UsersDb

    If it is still not working, I suggest you could reinstall the EntityFramework or create a new project to test it.

    Best Regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 19, 2015 5:50 AM

All replies

  • User2024324573 posted

    In the Package Manage Console, make sure you are choosing the right package source and the right project in the Default Project box

    You can set the package sources in you Visual Studio from Tools->Options->NuGet Pacakage Manager->Package Sources as below:

    Hope this will help.

    Regards,

    Mostafa

    Wednesday, June 17, 2015 10:46 PM
  • User-910579361 posted

    hello mostafasydney

    thx for your reply.
    Unfortunately this is not the problem. I have selected the right package source and project. 

    do you have other suggestions ?

    Wednesday, June 17, 2015 11:21 PM
  • User2024324573 posted

    What version of Visual Studio and EF are you using?

    Look at this thread: http://forums.asp.net/t/1723258.aspx?Exception+from+HRESULT+0x80070057+E_INVALIDARG+

    Wednesday, June 17, 2015 11:30 PM
  • User-910579361 posted

    Iam using VS 2013 and EF 6.1.3
    do you know where i will find \Temporary ASP.NET Files\ folder in Windows 8 ?

    Thursday, June 18, 2015 12:18 AM
  • User2024324573 posted

    have a look at this: http://weblogs.asp.net/psheriff/clean-up-after-visual-studio

    Thursday, June 18, 2015 12:54 AM
  • User-271186128 posted

    Hi kkooaa,

    PM> Enable-Migrations

    System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
    

    According to the tutorial, I create a sample on my side (VS2013, EF6, windows 8), it worked well. I sugget you could check the EntityFramework and make sure that EntityFramework is setup correctly for your seperate "Models" project. Here is a similar thread, please refer to it. http://stackoverflow.com/questions/14007169/entityframework-enable-migrations-argumentexception

    The solution which is contains in above link:

    If you run into the same problem, make sure that EntityFramework is setup correctly for your seperate "Models" project.

    • Open "Manage NuGet packages for solution" in solution explorer (right click solution in solution explorer)
    • Select "Installed packages"
    • Select "EntityFramework" and click "Manage"
    • Check your "Models" project (I checked both my website project and the "models" project)

    Run your enable-migrations command again.

    I also added a project reference from my Website project to the Models project, I don't know if that matters.

    The command that successfully executed after my adjustments in NuGet:

    enable-migrations -ProjectName Models -ContextTypeName Models.Users.UsersDb

    If it is still not working, I suggest you could reinstall the EntityFramework or create a new project to test it.

    Best Regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 19, 2015 5:50 AM