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
HiLo sequences are being dropped when specifying a default schema #28223
I'm having an issue where with each new migration file being generated our HiLo sequences are being dropped. This only happens if I add a default schema to the DbContext. This is the result when creating new migrations:
Here is the necessary code to reproduce this issue:
protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){modelBuilder.HasDefaultSchema("MyDefaultSchema");modelBuilder.HasSequence<int>("HiLoTestSeq","MyDefaultSchema").StartsAt(10)// Make provision for defaults.IncrementsBy(5);}publicclassTestSchemaEntity{publicintId{get;privateset;}}internalclassTestSchemaEntityTypeConfiguration:IEntityTypeConfiguration<TestSchemaEntity>{publicvoidConfigure(EntityTypeBuilder<TestSchemaEntity>builder){builder.ToTable("TestSchemaTable","MyDefaultSchema");builder.HasKey(r =>r.Id);builder.Property(r =>r.Id).UseHiLo("HiLoTestSeq","MyDefaultSchema");}}
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Window 11
IDE: Visual Studio 2022 16.3
Looks like this stems from some very strange behavior in FindSequence.
modelBuilder.HasDefaultSchema("dbo").HasSequence("TheSequence");// Not foundmodel.FindSequence("TheSequence","dbo");// Found. Result's schema is dbomodel.FindSequence("TheSequence");
modelBuilder.HasDefaultSchema("dbo").HasSequence("TheSequence","dbo");// Foundmodel.FindSequence("TheSequence","dbo");// Not foundmodel.FindSequence("TheSequence");
Activity
bricelam commentedon Aug 31, 2022
Looks like this stems from some very strange behavior in FindSequence.
Differentiate between a sequence's database schema and model schema
Differentiate between a sequence's database schema and model schema