Using HasData with new lines breaks the migrations
Describe what is not working as expected. I create a HasData that has a new line in it, and the corresponding HasData doesn't deal with new lines, Need to add @"" to make it work.
Steps to reproduce
- Add HasData with a new line:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Product>()
.HasData(new Product()
{
Id = 1,
Title = "Temp",
ArtDescription = @"In Rembrandt’s time, peacocks were a delicacy for the well-to-do: the meat was used as filling for pasties. After being slaughtered, the birds were hung upside down to drain their blood, as Rembrandt has depicted
in this pantry. He must have been fascinated by the plumage’s magnificent markings and dazzling colours:
blue, green and yellow ochre."
});
}
- Do "dotnet ef migrations add Seeding"
- Compile project and fails because of new lines in generated code.
Further technical details
EF Core version: 2.1.1 Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Win10 Pro IDE: (e.g. Visual Studio 2017 15.7)
@shawnwildermuth What generated code does the "dotnet ef migrations add Seeding" command generate? I was a bit confused... are you saying that doing @"" solves the problem? As a workaround, I recommend using FluentMigrator.
@ajcvickers I feel you should push customers harder on submitting complete repros. How much time does Microsoft waste even building test repros for this stuff?
@jzabroski In cases where it looks pretty clear what the issue is without a repro we tend not to ask. This is one such case. That is, I haven't attempted to repro it, but it seems pretty clear why it would happen and that it is a bug.
In general, we need to strike a balance between spending time investigating and being too dogmatic about issues such that people don't feel like reporting them, since that would also be bad for us. The key is always whether or not we can understand and reproduce what is going on. If we can, then good. If not, then we ask for more info.
@AndriySvyryd I was not able to find the dupe for this.
Then it's not a dupe
Sorry I missed this. The Github notifications app is down on my phone. I can give you a repro if you like.
If you do, I'll take a stab at fixing it.
On Tue, Jul 10, 2018 at 6:51 PM, Shawn Wildermuth [email protected] wrote:
Sorry I missed this. The Github notifications app is down on my phone. I can give you a repro if you like.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aspnet/EntityFrameworkCore/issues/12542#issuecomment-403990748, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbT_c-Xn1EB5bR-2WZ7nKlwtbdmqpWuks5uFTAEgaJpZM4VBsGn .
Ok, the real problem with is newline only (not /r/n but just /n as in my case with a Json file from a non-windows line ending). Here is a repro case:
https://github.com/shawnwildermuth/NewLineHasDataMigrationIssue
@jzabroski Update this line. 😉
Is it fixed ?
@usamakhalil86 Yes, in 2.2.0 If you are still experiencing it open a new issue with a small repro project