timabell / ef-enum-to-lookup

Generates lookup tables from enum references in Microsoft Entity Framework 6.1
https://www.nuget.org/packages/ef-enum-to-lookup
69 stars 29 forks source link

Lookup table does not include custom table name syntax #49

Closed aldav82 closed 8 years ago

aldav82 commented 8 years ago

When configuring the final table names, the lookup table will not follow the pattern. e.g.

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Types().Configure(entity => entity.ToTable("PREFIX_" + entity.ClrType.Name));
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
    }

All the generated tables are named "PREFIX_***" except enum ones, which are called "Enum_XXXXX". This might be a problem when we have multiple applications sharing the same database, given the case both applications have an exactly equally named enum.

timabell commented 8 years ago

That's because the lookup tables aren't generated by EF. You can tell this library about your own prefix by setting the TableNamePrefix property.

https://github.com/timabell/ef-enum-to-lookup/blob/master/EfEnumToLookup/LookupGenerator/EnumToLookup.cs#L53