Skip to content

Disable Naming Scheme? Is there a way I disable the naming scheme for ALL entities (except the enum types) #24

@jeffward01

Description

@jeffward01

Hello!

I'd like to configure my database table naming scheme manually within my IEntityTypeConfigureation<> classes. I don't want SpatialFocus/EntityFrameworkCore.Extensions to apply any NamingScheme to any non-enum classes at all.

For context, this is my use-case

  • I am using SpatialFocus/EntityFrameworkCore.Extensions for the enum to table features
  • I only want SpatialFocus/EntityFrameworkCore.Extensions to work with enums in this table capacity
  • I do not want SpatialFocus/EntityFrameworkCore.Extensions to touch my other 'non-enum' tables

Is it possible to disable this without manually selecting all entities to exclude?

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppIdentityUserConfiguration).Assembly);

        modelBuilder.ConfigureEnumLookup(
            EnumLookupOptions.Default.UseNumberAsIdentifier()
                .UseEnumsWithAttributeOnly()
                .SetDeleteBehavior(DeleteBehavior.NoAction));

        modelBuilder.ConfigureNames(
            NamingOptions.Default.SkipEntireEntities(_ => _.Name.Length > 0) // <--- It would be nice to not do this
        );
    }

This is the result if I specify:

        modelBuilder.ConfigureNames(
            NamingOptions.Default.SkipEntireEntities(_ => _.Name.Length > 0) // <--- It would be nice to not do this
        );

image

If I do not specify the above code snippet, then all tables will be styled to the configuration of the enum which in this example is snake_case with ClrType

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions