Thursday, June 4, 2015

Invalid object name 'dbo.__MigrationHistory'

Recently I faced an issue with Entity Framework 6.0. The error did not crashed the website, but I got it frequently in event viewer. To resolve this, I just added a line in DbContext's constructor:

public DatabaseContext() : base("name=Sample")

If you use an existing database with Code First approach, you may not want to execute any initialization code. You can disable the database initialization process altogether by passing null to SetInitializer() method