-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
SaveChanges circular dependency in unique unfiltered index #29647
Comments
A workaround for this is to define a filter:
This doesn't repro on SQL Server because the provider defines a filter whenever the index contains a nullable column. |
Will this change be released with 7.0.x patch? If yes, is there a planned date / version? |
No, the fix is too risky to be shipped in a patch. Are you not able to use the workaround mentioned above? |
Maybe then this fix will reach any of 7.x version? Or is it planned only for 8.0.0 version? 😄 We can use the workaround, but as an outcome it requires us to re-create the indexes on a database which we want to avoid. |
I need the fix too and can not use the workaround due to the fact that it would require too much downtime and is too risky. We (me and my company) would skip 7 entirely if its not fixed. |
It's a serious bug and without this fix EF7 is unusable imo. Very sad to see how this develops. |
You can edit the generated migration and remove the commands that recreate the indexes. The filters don't need to be in the database, EF just needs to assume that the index is filtered.
Another workaround is to use the daily builds. The 8.0 branch currently has no new features and has more bug fixes. This should be mostly the case until preview 1. |
That's not true, is it? https://github.com/dotnet/efcore/issues?q=is%3Aissue+milestone%3A8.0.0+label%3Atype-enhancement+is%3Aclosed I find the support strategy quite bizarre. EF 7 is only 1 month into its 18 months of support but there are already bugs that are too risky to patch? Isn't it better to fix known bugs which are already there rather than be very conservative against unknown bugs?* If you accidentally introduce a bug, then there is good news - there are still 17 months of support in which you can fix the new bug too :) *probably a bad example because 5.0.1 introduced a bad bug :D |
I meant no new big features that could still be buggy.
We'll discuss this again. The issue is that it might take up to two months since the bug is reported for the fix to be shipped in a patch, depending on factors we don't control. |
Note from triage: we will take a patch to Tactics with the understanding that it is not low risk and so may be rejected. |
Hi guys. I have tried 7.03 and simple test like that fails for me with the same exception: // https://github.com/dotnet/efcore/issues/29647
[Fact]
public void SaveChangesShouldNotThrow()
{
var context = new TestDbContext();
var e = new TestEntity { Id = Guid.NewGuid(), Name = "n1" };
var e2 = new TestEntity { Id = Guid.NewGuid(), Name = "n2" };
context.TestEntities.Attach(e);
context.TestEntities.Attach(e2);
context.Entry(e).Property(p => p.Name).IsModified = true;
context.Entry(e2).Property(p => p.Name).IsModified = true;
context.SaveChanges();
}
public class TestDbContext : DbContext
{
public DbSet<TestEntity> TestEntities { get; set; }
protected override void OnConfiguring(
DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured || optionsBuilder.Options.Extensions.Count() <= 1)
{
optionsBuilder.UseSqlServer("Server=.;Initial Catalog=test;User Id=sa;Password=test;TrustServerCertificate=true");
base.OnConfiguring(optionsBuilder);
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<TestEntity>()
.HasKey(t => t.Id);
modelBuilder.Entity<TestEntity>()
.HasIndex(t => new { t.Id1, t.Id2 })
.IsUnique();
}
}
public class TestEntity
{
public Guid Id { get; set; }
public string Name { get; set; }
public Guid Id1 { get; set; }
public Guid Id2 { get; set; }
} Exception:
I assume that updated with only name field should be generated. It was working fine prior in ef core 6.*. Thanks |
@jmalczak In your case the |
Hey, but I don't mark them as modified. What sense does it make to even check them if they won't be part of final update statement? |
Indeed. Please file a new issue for this. |
@AndriySvyryd thanks, here it is #30601. |
#28065 raised a 7.0 SaveChanges circular dependency issue with unique indexes; two repros were posted there - one with a filtered index, one without. The fix for that issue (#28923) seems to have fixed only the filtered index case, but the unfiltered one still fails on 7.0.
Repro
/cc @AndriySvyryd
The text was updated successfully, but these errors were encountered: