Closed mjr27 closed 8 months ago
Between 8.0.0-rc.2 and 8.0.0 a regression occured that breaks existing code.
Long story short, the library used to generate names based on DbSet name, and it started to generate it based on entity name.
Sample program:
WebApp.sln :
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="EFCore.NamingConventions" Version="8.0.0-rc.2"/> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0"/> </ItemGroup> </Project>
Program.cs:
using System; using Microsoft.AspNetCore.Builder; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Services .AddDbContext<SampleDbContext>(o => o.UseSqlite("Data Source=data.sqlite")); WebApplication app = builder.Build(); using IServiceScope scope = app.Services.CreateScope(); SampleDbContext db = scope.ServiceProvider.GetRequiredService<SampleDbContext>(); db.Database.EnsureCreated(); public class DbEntity { public required Guid Id { get; set; } } public class SampleDbContext : DbContext { public DbSet<DbEntity> DbTable { get; set; } = null!; public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options) { } /// <inheritdoc /> protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSnakeCaseNamingConvention(); base.OnConfiguring(optionsBuilder); } }
Behavior on 8.0.0-rc.2:
info: Microsoft.EntityFrameworkCore.Database.Command[20101] Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] CREATE TABLE "db_table" ( "id" TEXT NOT NULL CONSTRAINT "pk_db_table" PRIMARY KEY );
Behavior on 8.0.0:
info: Microsoft.EntityFrameworkCore.Database.Command[20101] Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] CREATE TABLE "db_entity" ( "id" TEXT NOT NULL CONSTRAINT "pk_db_entity" PRIMARY KEY );
Duplicate of #247
Between 8.0.0-rc.2 and 8.0.0 a regression occured that breaks existing code.
Long story short, the library used to generate names based on DbSet name, and it started to generate it based on entity name.
Sample program:
WebApp.sln :
Program.cs:
Behavior on 8.0.0-rc.2:
Behavior on 8.0.0: