You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Seeding data via HasData that contains new lines includes undesired tabs when a migration is generated #20662
Seeding data via HasData that contains new lines includes undesired tabs when a migration is generated. The string outputted in the migration is not equal to the one in HasData method.
This only appears to happen when the migration produces InsertData call and values being seeded in is formed as a jagged array.
Steps to reproduce
I'm unable to reproduce this reliably, but here's a rough example of what's happening locally for me:
Given the following seed,
protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){base.OnModelCreating(modelBuilder);modelBuilder.Entity<TestModel>().HasData(newTestModel(){Id=1,Description=@"This is a test.Notice the linebreak."},newTestModel(){Id=2Description=@"This is a second test.Notice the linebreak."},...100 more of thesewith linebreaks
);}
If you generate a migration, the InsertData is scripted as following:
migrationBuilder.InsertData(table:"TestModel",columns:new[]{"Id","Description"},values:newobject[,]{{1,@"This is a test. Notice the linebreak."},{2,@"This is a second test. Notice the linebreak."}});
It appears the migration tool is attempting to format the insertdata call by inserting indents. But the strings are no longer equal. It's also worth noting that this doesn't happen when the migration generates the InsertData calls separately rather than as a single call.
EF Core version: 3.1.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows 10
Activity