Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow with code first migration #23156

Closed
vsfeedback opened this issue Oct 30, 2020 · 2 comments
Closed

Stack overflow with code first migration #23156

vsfeedback opened this issue Oct 30, 2020 · 2 comments

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version of Visual Studio]
Major issue.

I have a migration that generates seed data, approximately 5,000 rows. The file is 14MB.

When I try to Update-Database the VBSC compiler goes nuts using 50-100% of my CPU (Intel Core i5-8400) and up to 3.5GB of memory. Then it hangs trying to apply and I get a Stack Overflow exception. So I can not seed my database with the required data set.

What's worse is, now I can not remove the migration. When I try to remove it I get the same Stack Overflow exception. This has effectively killed my branch which has critical data.

In the past, I've seeded data far larger than this this without issues. This is a major breaking issue.

Stack overflow.
   at Quill.Data.Migrations.pddr_definitions_4.Up(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)
   at Microsoft.EntityFrameworkCore.Migrations.Migration.BuildOperations(System.Action`1<Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder>)
   at Microsoft.EntityFrameworkCore.Migrations.Migration.get_UpOperations()
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql(Microsoft.EntityFrameworkCore.Migrations.Migration, Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerationOptions)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator+<>c__DisplayClass16_2. <GetMigrationCommandLists>b__2()
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(System.String)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(System.String, System.String, System.String)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(System.String, System.String, System.String)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor+UpdateDatabase+<>c__DisplayClass0_0. <.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor+OperationBase.Execute(System.Action)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor+UpdateDatabase.. ctor(Microsoft.EntityFrameworkCore.Design.OperationExecutor, Microsoft.EntityFrameworkCore.Design.IOperationResultHandler, System.Collections.IDictionary)
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean, Boolean)
   at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Activator.CreateInstance(System.Type, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, System.Object[])
   at System.Activator.CreateInstance(System.Type, System.Object[])
   at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor.Execute(System.String, System.Object, System.Collections.IDictionary)
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Runtime.CompilerServices.CallSite, System.__Canon, System.__Canon, System.__Canon, System.__Canon)
   at Microsoft.EntityFrameworkCore.Tools.OperationExecutorBase.InvokeOperationImpl(System.String, System.Collections.IDictionary)
   at Microsoft.EntityFrameworkCore.Tools.OperationExecutorBase.InvokeOperation(System.String, System.Collections.IDictionary)
   at Microsoft.EntityFrameworkCore.Tools.OperationExecutorBase.UpdateDatabase(System.String, System.String, System.String)
   at Microsoft.EntityFrameworkCore.Tools.Commands.DatabaseUpdateCommand.Execute(System.String[])
   at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase+<>c__DisplayClass0_0. <Configure>b__0(System.String[])
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(System.String[])
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(System.String[])

Original Comments

(no comments)


Original Solutions

(no solutions)

@ajcvickers ajcvickers transferred this issue from dotnet/ef6 Oct 30, 2020
@ajcvickers
Copy link
Contributor

Related: #14922

@ajcvickers
Copy link
Contributor

Closing as a duplicate of #14922, which covers a better experience for large seed data. Workarounds to try:

  • Use actual entity types in seed data rather than anonymous types
  • Split the migration Up/Down methods into multiple methods
  • Remove the seed data from the migration and use more traditional methods to seed the database.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants