loresoft / EntityFrameworkCore.Generator

Generate Entity Framework Core model from an existing database
https://efg.loresoft.com/
MIT License
380 stars 95 forks source link

Navigation Propery Name #69

Open taraman opened 4 years ago

taraman commented 4 years ago

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 commented 4 years ago

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

ehpmfigueroa commented 1 year ago

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 commented 5 months ago

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

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'
}