diff --git a/src/TickerQ.EntityFrameworkCore/Configurations/CronTickerConfigurations.cs b/src/TickerQ.EntityFrameworkCore/Configurations/CronTickerConfigurations.cs index c87f5f7e..a17ebad3 100644 --- a/src/TickerQ.EntityFrameworkCore/Configurations/CronTickerConfigurations.cs +++ b/src/TickerQ.EntityFrameworkCore/Configurations/CronTickerConfigurations.cs @@ -27,9 +27,7 @@ public void Configure(EntityTypeBuilder builder) .HasDatabaseName("IX_Function_Expression"); builder.Property(e => e.IsEnabled) - .IsRequired() - .HasDefaultValueSql("1") - .HasSentinel(true); + .IsRequired(); builder.ToTable("CronTickers", _schema); } diff --git a/tests/TickerQ.EntityFrameworkCore.Tests/Infrastructure/CronTickerConfigurationTests.cs b/tests/TickerQ.EntityFrameworkCore.Tests/Infrastructure/CronTickerConfigurationTests.cs index 4a38c686..78ceeed1 100644 --- a/tests/TickerQ.EntityFrameworkCore.Tests/Infrastructure/CronTickerConfigurationTests.cs +++ b/tests/TickerQ.EntityFrameworkCore.Tests/Infrastructure/CronTickerConfigurationTests.cs @@ -1,8 +1,6 @@ using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; - -using TickerQ.EntityFrameworkCore.Configurations; using TickerQ.Utilities.Entities; namespace TickerQ.EntityFrameworkCore.Tests.Infrastructure; @@ -33,18 +31,22 @@ public async Task DisposeAsync() } [Fact] - public void IsEnabled_Uses_DefaultValueSql_Not_DefaultValue() + public void IsEnabled_Has_No_Database_Default() { var entityType = _context.Model.FindEntityType(typeof(CronTickerEntity))!; var property = entityType.FindProperty(nameof(CronTickerEntity.IsEnabled))!; - // HasDefaultValueSql sets the relational default SQL, not the CLR default value - var relational = property.GetDefaultValueSql(); - Assert.Equal("1", relational); + // No database default — the CLR property initializer (= true) handles the default. + // This avoids any provider-specific SQL translation concerns. + Assert.Equal(ValueGenerated.Never, property.ValueGenerated); + Assert.Null(property.GetDefaultValueSql()); + } - // The sentinel is set to true so EF Core sends false explicitly - var sentinel = property.Sentinel; - Assert.Equal(true, sentinel); + [Fact] + public void IsEnabled_CLR_Default_Is_True() + { + var entity = new CronTickerEntity(); + Assert.True(entity.IsEnabled); } [Fact] @@ -59,8 +61,8 @@ public void IsEnabled_Is_Required() [Fact] public async Task Insert_CronTicker_Without_IsEnabled_Gets_Default_True() { - // The C# property initializer sets IsEnabled = true, - // and the database default is 1 — both paths produce true. + // The C# property initializer sets IsEnabled = true; + // EF Core always includes it in the INSERT — no DB default needed. var ticker = new CronTickerEntity { Id = Guid.NewGuid(),