MaxIdentifierLength is not supported
gscpw opened this issue · 4 comments
I use MaxIdentifierLength
limit to support Oracle:
public class OpenIddictDbContext : DbContext
{
public OpenIddictDbContext(DbContextOptions options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Oracle limit
modelBuilder.Model.SetMaxIdentifierLength(30);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSnakeCaseNamingConvention();
}
However, it seems setting the snake_case naming convention ignores the max identifier length and instead generates full-length identifiers. If I do not add snake_case naming convention, the identifiers are limited to 30 chars and are protected against conflict by appending ~
, ~1
, ~2
, etc.
Hello, any progress? I have the same problem
No progress as of now - I'll probably concentrate on the plugin a bit later in the release, before 8.0 is released.
This seems to be specifically a problem when the table name is derived from a DbSet property name; otherwise, if there's no DbSet property, the table name is truncated properly (property names are also truncated).
@AndriySvyryd is it safe to assume that this is a conflict/ordering issue between the convention that sets the table name from the DbSet and the naming rewriting convention?
Repro
public class BlogContext : DbContext
{
// Commenting out the following makes truncation work
public DbSet<StudentWithAVeryLongNameExceedingTheMaximum> StudentsWithAnotherLongName { get; set; } = null!;
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseNpgsql("Host=localhost;Username=test;Password=test")
.UseSnakeCaseNamingConvention()
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Model.SetMaxIdentifierLength(10);
modelBuilder.Entity<StudentWithAVeryLongNameExceedingTheMaximum>();
}
}
public class StudentWithAVeryLongNameExceedingTheMaximum
{
public int Id { get; set; }
public string? PropertyNameThatIsVeryLong1 { get; set; }
public string? PropertyNameThatIsVeryLong2 { get; set; }
}
There's definitely a conflict, but I couldn't say where the fix for it should be without investigating the root cause.