-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add table name to AddHandlebarsTransformers propertyTransformer #189
Comments
Looks like this may be a duplicate of #188. Please re-open if this is not the case. |
Does not look to be the same issue. |
@johnwc AddHandlebarsTransformers now accepts arguments with an IEntityType parameter, which allows you to get the table name by calling the GetTableName extension method. Will this fulfill your need? |
Yes, that will work perfectly. When will this update be released? |
@johnwc It's included with the v6.0.0 release, which I published to NuGet yesterday. |
@johnwc Please re-open if you need further help. |
So, trying to determine the property to set. I wrote this quick debug code to see what it comes up with, since I can't step through the code. Why is it coming up twice? services.AddHandlebarsTransformers2(
propertyTransformer: (i, e) =>
{
var table = i.GetTableName();
switch (table)
{
case "fan_events":
switch(e.PropertyName)
{
case "Status":
Console.WriteLine("propertyTransformer: {0}.{1}: {2}", table, e.PropertyName, e.PropertyType);
break;
}
break;
}
return e;
}); Outcome... > dotnet ef dbcontext scaffold "..." "Pomelo.EntityFrameworkCore.MySql" --force -o DAL -c MCDb --no-onconfiguring
Build started...
Build succeeded.
Using ServerVersion '8.0.23-mysql'.
propertyTransformer: fan_events.Status: FanEvent <-- ????
propertyTransformer: fan_events.Status: int |
@johnwc I just noticed the same thing while working on #216 . @tonysneed Is this intentional? If not, I'll try to fix this alongside 216. |
@tonysneed @Herdo finally getting around to wanting to rename nav properties and ran into an issue. We have a table called Here is a console debug to help explain. navPropertyTransformer: (i, e) =>
{
var table = i.GetTableName() ?? i.GetViewName();
Console.WriteLine("navPropertyTransformer: {0}.{1}: {2} {3}", table, e.PropertyName, e.PropertyType, i.Name);
return e;
} One of those belongs to the inverse property for
|
@johnwc EF Core Power Tools now has property renaming, just FYI |
@ErikEJ If I rename a navigation property, then do a scaffold will the name change persist? |
Yes, you need to configure renaming once in a json file |
@ErikEJ Where can I find documentation how to do it? Can I use diagram to rename it? |
Docs are in the EF Core repo wiki, and no |
@ErikEJ does the renaming json file support setting the type for a column? Like changing int to a Enum? Is there documented schemas for the json files so I can read all what can be configured with them? |
Did you read the wiki. No enum renaming, there are other ways to do that, as documented. |
@ErikEJ yes, I read through the wiki and saw no documentation on schema for json files. Can I use my existing AddHandlebarsScaffolding with your tool? So it can take care of the type modifications. We're not wanting to take on managing T4/handlebar templates just to change int to enum for a handful of properties. |
@johnwc The format and feature is documented here: https://github.com/ErikEJ/EFCorePowerTools/wiki/Reverse-Engineering#custom-renaming-with-efptproperty-renamingjson
Yes, I believe so, what have you tried? |
My understanding is that |
@tonysneed Sorry, you are correct. Misunderstood the question |
@tonysneed seeing EFC PT doesn't support calling @ErikEJ is there any plans to include allowing to call |
Would you be able to propose a solution? If you like, you can open a new issue for this and submit a PR with the solution. |
@tonysneed Unfortunately I had surgery on my shoulder last week and I am down to like 20% productivity. So, it would take me a while to produce a PR for you. If you would like me to create a new issue for this, I can though? To stay backward compatible, my proposal would be to create a new class named In reality what I was expecting it to be like, was that for the navPropertyTransformer: (i, e) =>
{
var table = i.GetTableName() ?? i.GetViewName();
Console.WriteLine("navPropertyTransformer: {0}.{1}: {2} {3}", table, e.PropertyName, e.PropertyType, i.Name);
return e;
} So this outcome...
I expected to be...
To not stay backward compatible, I propose the IEntityType for navPropertyTransformer be changed to using the entity type that the nav property belongs to. Ex: |
As the title explains, add the table name to the propertyTransformer function for AddHandlebarsTransformers so that we know what table/class the property is for.
The text was updated successfully, but these errors were encountered: