I have my Migration which has a number close to 6500 records like this:
db.MinhaLista.AddOrUpdate(x => x.Codigo, (new MeuModel { Codigo = "ABC1234", Nome = "Teste "}));
However while running my migrations as follows:
var migration = new DbMigrator(new Configuration());
migration.Update();
Causes the following exception:
An unhandled exception of type 'System.StackOverflowException' occurred
//Descrição:
{Cannot evaluate expression because the current thread is in a stack overflow state.}
What I currently tested and checked was:
[Edit] The call to this migrator is using SetInitializer
static DbContext()
{
Database.SetInitializer<AppDbContext>(new CustomAndMigrationDatabase<DbContext, Configuration>());
}
Where class CustomAndMigrationDatabase
receives DbContext and Configuration, thus performing the instance of DbMigrator as follows:
var migration = new DbMigrator(new TMigrationsConfiguration());
if (migration.GetPendingMigrations().Any())
{
migration.Update();
}