msawczyn / EFDesigner2022

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
118 stars 21 forks source link

When importing from assembly, detect and generate foreign keys #36

Closed msawczyn closed 6 months ago

msawczyn commented 3 years ago

Split from msawczyn/EFDesigner#225 as a separate issue; submitted by alprinias

... (when) importing from an existing database.

The database tables had their foreign keys defined and their names were not always simple, e.g. Table_Id. These were imported to the model and designer, but the model then created new properties for the associations. Fair enough, I would not expect the designer to know which column refers to which association. I then had to expose the foreign keys (at model level) and go through each association and set the foreign key column name to the already existing in the table, which resulted in the little blue key icon to appear next to the column names. But in this way I am "obliged" to expose the foreign keys in the models. If I go and select "false" for exposing the foreign keys at model level, the foreign key names I set are lost.

So, I think an enhancement would be to be able to set the foreign key name even if the foreign keys are not exposed in the model.