msawczyn/EFDesigner

Recognize "Id" as primary key on import

JorgenLindell opened this issue · 4 comments

I started trying this out today by importing a set of EF Core classes.

One thing that I had to do was to go through 50+ classes and mark the Id field as primary key.
EF Core automagically recognizes Id as being the primary key, so that doesn't need to be tagged by an attribute.
It would be practical if you could set an option to make EFDesigner do the same.

That's an excellent idea.

To clarify, you're talking about drag/drop import of code onto the design surface, yes? The tool would, if it sees a property named Id, tag that property as an identity property when it imports the dropped class. Do I have that right?

Yes, but probably only if no other key is set to be key

The convention is defined in https://docs.microsoft.com/en-us/ef/core/modeling/keys
as "By convention, a property named Id or <type name>Id will be configured as the key of an entity."

Yes, should have said that. Would be quite rude to step on user-defined identity properties :-)

Thanks for the suggestion. I've got that going into the next release.

Had a moment so pushed the change out. It's in v1.2.5.