14

Im having trouble with my migration to my database and i can't seem to find a answer to the error i am getting

 System.MissingMethodException: Method not found: 'System.Data.Entity.Migrations.Builders.TableBuilder`1 System.Data.Entity.Migrations.Builders.TableBuilder`1.Index(System.Linq.Expressions.Expression`1>, Boolean, Boolean, System.Object)'.
   at Evento.Migrations.initialcreate.Up()
   at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.c__DisplayClassc.b__b()
   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.c__DisplayClass2.b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Method not found: 'System.Data.Entity.Migrations.Builders.TableBuilder`1 System.Data.Entity.Migrations.Builders.TableBuilder`1.Index(System.Linq.Expressions.Expression`1>, Boolean, Boolean, System.Object)'. 
5
  • what version of EF are you using? and what framework version (4/4.5)? Commented Mar 25, 2014 at 16:49
  • 2
    it sounds to me something related to EF has not installed properly. Have you try to uninistall and install EF ? Commented Mar 25, 2014 at 17:21
  • 2
    Reinstalling EF seems to have made it work. Now i have other issues instead. Thank you Commented Mar 25, 2014 at 18:30
  • 6
    I just experienced the exact same error - in my case, I had a multi-project solution. The project containing the entities and context had Entity Framework v6.1.0, the Startup (Web) project was still associated with Entity Framework v6.0.2. When publishing the app for the first time, I got a similar exception. The error was resolved after I made the versions consistent (6.1.0) across the projects.
    – Jason
    Commented Apr 16, 2014 at 13:08
  • +1 to @Jason answer. Updating my EF version across all projects fixed this issue.
    – DanielC
    Commented Jun 12, 2014 at 13:36

5 Answers 5

17

I ran into this same issue and here is how I resolved it. I hope this helps someone else.

  1. I deleted Entity Framework from my References and removed the lines from my package.config file(s).
  2. Closed Visual Studio and deleted all the EntityFramework DLL files in my project folders
  3. Opened Visual Studio, then did a Clean and Build
  4. Re-install Entity Framework
  5. Did a Clean and Build again

After that, it was working.

4
  • Your steps seem trivial, but they actually do work! Thanks a lot man! Commented Apr 22, 2015 at 5:33
  • 1
    How did clean build at step 3 work when you had removed entity framework? Commented Jan 10, 2017 at 17:20
  • @PaulMcCarthy I'm sure that you've solved the issue by now but for others what I did was: comment out the offending code that was causing compile errors due to the dll/nuget packages being removed, then did the clean and build. Commented May 6, 2018 at 23:29
  • I didn't have to do a clean build as mentioned above. I removed EF nuget, closed VS, deleted the entire packages folder, restarted VS, re-added EF then rebuilt and deployed the package and it worked perfectly. Thank you for pointing me in this direction.
    – Amogh Natu
    Commented Oct 15, 2019 at 18:40
5

This can also happen if Entity Framework is included in a referenced project but not in the project from where you are initializing the migration. Solution is to include EF in that project as well.

3
  • is happening something like this. But I cant get it work
    – fiorebat
    Commented Feb 29, 2016 at 11:48
  • 1
    my fault, referenced dll was different from nuget installed :(
    – fiorebat
    Commented Feb 29, 2016 at 12:04
  • 1
    @fiorebat I had the same problem here. Commented Mar 23, 2018 at 16:59
4

This can happen if you are running an older version of migrate.exe against a new dll using EF 6.2.0

2

I ran into this error when running db.Database.Initialize(true);. I discovered that my the console app was referencing EF v 6.0, but the project with the DataContext and ModelBuilder were 6.1.3.

The error went away after setting the console app to 6.1.3 to match the others.

0

If you are using EF 6.1, you need to install update 2 for Visual Studio 2013

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.