ErikEJ / erikej.github.io

ErikEJ blog
3 stars 1 forks source link

EF Core Power Tools database reverse engineering: renaming of entities and properties #19

Open ErikEJ opened 3 years ago

KayakFisher205 commented 3 years ago

When using 2.4.217.0, EF Core 5.0 Preview, Advanced, Generate stored procedure Mappings (preview) on a database, it works great. When I pointed to another database, there was a DbContextExtensions.cs file in the new folder that was conflicting with the first one, for a different database, in a different folder. If I move the static class of each of the DbContextExtensions.cs files to a namespace, based on the folder path, it works fine. I didn't know if there was something I needed to do when I used the tool or if this was a bug, or by design.

ErikEJ commented 3 years ago

I usually do not recommend having multiple DbContexts in the same project. But please file an issue, it should be possible to do better.

KayakFisher205 commented 3 years ago

The tool creates one each time I point to a different database. I have a website that pulls from 5 different systems. I believe by adding a Namespace around the class will fix the issue. Or, allow to rename. If you think that would work, I can put in an issue.

ErikEJ commented 3 years ago

Yes, using the namespace will probably solve it.

ErikEJ commented 3 years ago

@KayakFisher205 Fixed in latest daily build

marcscheuner commented 3 years ago

This does not seem to work for collection-level properties.

I tried to rename my property

    public virtual ICollection<Attachment> Attachment { get; set; }

to be renamed to

    public virtual ICollection<Attachment> Attachments { get; set; }

but that doesn't happen ... should it? Or if not: could that be a new feature to add to the renaming functionality soonish?

ErikEJ commented 3 years ago

@marcscheuner duplicate of https://github.com/ErikEJ/EFCorePowerTools/issues/211