Skip to content

Commit

Permalink
Make unique index topological dependency optional for null values
Browse files Browse the repository at this point in the history
Fixes #29647
  • Loading branch information
AndriySvyryd committed Dec 7, 2022
1 parent 27642d1 commit 5fbeaec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
modelBuilder.Entity<ProductTableWithView>().HasBaseType((string)null).ToView("ProductView").ToTable("ProductTable");
modelBuilder.Entity<ProductTableView>().HasBaseType((string)null).ToView("ProductTable");

modelBuilder.Entity<Product>().HasIndex(p => new { p.Name, p.Price }).IsUnique().HasFilter("Name IS NOT NULL");
modelBuilder.Entity<Product>().HasIndex(p => new { p.Name, p.Price }).IsUnique();

modelBuilder.Entity<Person>(pb =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con

modelBuilder.Entity<ProductBase>()
.Property(p => p.Id).HasDefaultValueSql("NEWID()");

modelBuilder.Entity<Product>().HasIndex(p => new { p.Name, p.Price }).HasFilter("Name IS NOT NULL");
}
public virtual void ResetIdentity()
{
Expand Down

0 comments on commit 5fbeaec

Please sign in to comment.