Skip to content
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

Navigation Propery Name #69

Open
taraman opened this issue Dec 26, 2019 · 3 comments
Open

Navigation Propery Name #69

taraman opened this issue Dec 26, 2019 · 3 comments

Comments

@taraman
Copy link

taraman commented Dec 26, 2019

Dear all
I like this tool as it generates entities for database views and can customize the output. the tiny issue I got when using Scaffold-DbContext for reverse engineering:
public Patent()
{
public virtual ICollection Inventors { get; set; }
}
but when generate with the generator tool, I got this:
public Patent()
{
public virtual ICollection PatentInventors { get; set; }
}

as you see the class name Patent has been concatenated to the property name, so can we have any custom way to keep only the navigation property name?

@pwelter34
Copy link
Member

If you refactor and rename the property, the changes should be kept upon re-generation. Is that not the case?

@ehpmfigueroa
Copy link

Navigation properties (generated relationships) are not being preserved upon re-generation even after renaming them through the IDE. The renamed properties revert back to the default auto generated names.

For example:

public partial class Person {
...
}

public partial class User {
#region Generated Properties
public int PersonID { get; set; }
public string Email { get; set; } // can rename this property just fine and the change is preserved upon re-generation
#endregion
#region Generated Relationships
public virtual Person FKPersonPerson { get; set; } // needs to be renamed to Demographics but the name reverts back after re-generation
#endregion
}

How can I rename the generated relationship property to the desired name and preserve said change so a re-generation won't revert it back?

@ArnaudB88
Copy link

@pwelter34 Currently renaming of 'generated relationships' are reverted upon regeneration.
Is it possible to extend the 'renaming functionality' so

  • a rename entry can also pass a 'replacement string'. This way we can specify a match (like now) and also a replace (which is currently string.empty in your code)
  • rename functionality also applies on 'generated relationships'. This way we can specify our renames in the yaml and regeneration won't revent them.

fyi I would like the rename functionality for generated relationships for the following example (hierarchical table):

class Project
{
    Guid Id  { get; set; }
    Guid? ParentProjectId  { get; set; }
    //Generated relationships
    virtual Project ParentProject  { get; set; }
    virtual ICollection<Project> ParentProjects  { get; set; }  //=> I want this to be named 'ChildProjects'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants