locked
Can't enable Migrations in Entity Framework 4.3 RRS feed

  • Question

  • I have a class library with EF Code First. I just upgraded to EF 4.3 and now I want to enable migrations.

    I type `Enable-Migrations -ProjectName MyProjectName` in the PM console but receive the following error

    PM> Enable-Migrations -ProjectName MyProjectName
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at System.Data.Entity.Migrations.DbMigrationsConfiguration.GetSqlGenerator(String providerInvariantName)
       at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext)
       at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
       at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
       at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.RunCore()
       at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
    The given key was not present in the dictionary.
    PM> 
    


    I cant figure out what dictionary that might be wrong.

    My connection string looks like this:

    <connectionStrings>
      <add name="MySystem" connectionString="Data Source=MyServer\Instance;Initial Catalog=myDbName;Integrated Security=True" providerName="System.Data.SqlClient" />
    </connectionStrings>

    Any idea about what might be wrong?

    Just a note:  
    I use my class library in a console application with an exact copy of my app.config and there I can access my database perfectly well.

    I have also posted the same question on http://stackoverflow.com/questions/9618857/cant-enable-migrations-in-entity-framework-4-3

    Thursday, March 8, 2012 2:20 PM

Answers

  • Your solution in StackOverFlow is greate, it also help me! Thanks! Anybody who encounters the same error, please refer here.

    Fighting like Allen Iverson. Neve give up!

    • Marked as answer by Allen_MSDN Friday, March 16, 2012 2:17 AM
    Sunday, March 11, 2012 3:18 PM