efcore / EFCore.NamingConventions

Entity Framework Core plugin to apply naming conventions to table and column names (e.g. snake_case)
Apache License 2.0
711 stars 73 forks source link

Expose internal classes #40

Open rfpedrosa opened 3 years ago

rfpedrosa commented 3 years ago

Sometimes, I end up defining how things should be named in the DB. For example:

.UseHiLo($"{nameof(MyClass).ToSnakeCase()}_hilo")

builder.OwnsMany(o => o.Contours, io =>
            {
                io.WithOwner();
                io.ToTable(nameof(ImagePoint).ToSnakeCase());
            });

I end up writing my own string extension to have consistent snake case naming but, ideally, I would reuse SnakeCaseNameRewriter:

  1. for a higher degree of consistency;
  2. do the same thing with less code (no need to define my own ToSnakeCase if the library I'm using also has that...
jmzagorski commented 3 months ago

I also have a use case for this that relates to table sharing. I've found that I need to call HasColumnName for two entities to share a table's column. It would be nice if there was a public method for this plugin that would convert our name to the convention we choose on DbContextOptionsBuilder<TContext> when we have to use HasColumnName. For example .HasColumnName(RewriteName(nameof(Entity.PropertyName))