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

Entity level attributes should use nameof() to facilitate refactoring #2313

Closed
InsanePup opened this issue May 9, 2024 · 4 comments
Closed
Labels
question Further information is requested

Comments

@InsanePup
Copy link

Not a bug per se, but a definite improvement to usability. When specifying property names, nameof() should be used to facilitate refactoring. Example of where this should be done...

[Table("ec_code")]
**[Index("CodeId", Name = "code_id", IsUnique = true)]**
[MySqlCharSet("utf8mb3")]
[MySqlCollation("utf8mb3_general_ci")]
public partial class EcCode
{
@ErikEJ
Copy link
Owner

ErikEJ commented May 9, 2024

I think this is by design, as nameof us not always correct.

@ErikEJ ErikEJ added the question Further information is requested label May 9, 2024
@ErikEJ ErikEJ closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
@InsanePup
Copy link
Author

I think this is by design, as nameof us not always correct.

Why not use it when it is correct?

@ErikEJ
Copy link
Owner

ErikEJ commented May 10, 2024

See this issue for more context: dotnet/efcore#26588

@InsanePup
Copy link
Author

I don't want to beat this to death, so please don't feel obliged to reply... but...
There are obviously scenarios where nameof() is appropriate, for instance in my original post. The Index attribute references a property in the same class. If you're saying that you can't reliably distinguish these scenarios then fair enough. For context, I encountered this issue within 30 minutes of first using the Power Tools, so it wasn't some rare edge case, at least for me. The capitalization of generated entity and property names is not perfect so I had quite a bit of clean-up to do, and refactoring tools are often less than perfect too.

On a tangent... Thank you for providing this tool. It has been a great time saver. If I was to suggest a feature for a future version, it would be the ability to specify relationship between entities prior to code generation. The MySQL db I am currently using does not have foreign keys explicitly defined, so I need to add code for the all the navigation properties, which has been a simple but cumbersome task.

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

No branches or pull requests

2 participants