Closed McDoit closed 1 year ago
Hi Erik,
The following callback should help you:
// Use the following list to replace column byte types with Enums.
// As long as the type can be mapped to your new type, all is well.
Settings.AddEnumDefinitions = delegate(List<EnumDefinition> enumDefinitions)
{
enumDefinitions.Add(new EnumDefinition { Schema = "dbo", Table = "ApiTypes", Column = "Id", EnumType = "ApiTypesEnum" });
};
But then I can't use automatic filtering/adding of Enums as in AddEnum
from a Table
Best would be to be able to add EnumDefinition
from the tables targeting a Table
i want defined as an Enum
But i don't know if its possible in how the script currently work, and the order parts are executed
@sjh37 I can kinda work around it, but then I need to have some extra Lists to temp store data in between the calls
What wold be the best way to do that? As it is now, if I define var enumTables = new List<string>();
it doesn't seem to be accessible from other delegates?
You could add an enumTables list to the Settings
class located at the top of the EF.Reverse.POCO.v3.ttinclude
file.
I'll have a play and report back.
Add EnumTables
to the top of the settings class like so:
public static class Settings
{
public static List<string> EnumTables = new();
...
}
And you can use that anywhere in your
Settings.EnumTables.Add("todo");
I will close this issue. Any problems, please let me know here.
I'm trying to achieve a workflow where i generate Enums from tables, find props in entities having a FK there and repalce the prop with the enum and then remove the navigation property from that entity
So a bit like this:
Table api.Types into a enum type like this (with
AddEnum
)and turn entity for table api.Users
into this
As the enum tables are just there for db constraints and dont want them as a navigation property
My problem is that
AddEnum
is called afterUpdateColumn
and similar calls, so I cant use the enums i generate inAddEnum
And a problem I have is that theFkEntity
property on column is empty, dunno if it is related to some other changes I madeIs there any better or other way to achieve this that I have missed?