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

Reverse-Engineer with schemas into directories #158

Closed
mikethibault opened this issue Jan 7, 2019 · 18 comments
Closed

Reverse-Engineer with schemas into directories #158

mikethibault opened this issue Jan 7, 2019 · 18 comments
Labels
enhancement New feature or request reveng

Comments

@mikethibault
Copy link

For reverse engineering with multiple schemas, an option to sort classes into schema-named directories would be very helpful.

@ErikEJ
Copy link
Owner

ErikEJ commented Jan 7, 2019

Why have all your tables in a single DbContext?

Why not two projects with a DbContext per schema? (You can do that today)

@ErikEJ
Copy link
Owner

ErikEJ commented Jan 13, 2019

Ping?

@mikethibault
Copy link
Author

My database has relationships between tables from different schemas. I'm unaware of a way that Entity Framework can allow joins between contexts without loading everything in memory. I think it'd be great to mirror this capability of database schemas in an EF Core context.

@ErikEJ ErikEJ added this to the Backlog milestone Mar 24, 2019
@ErikEJ
Copy link
Owner

ErikEJ commented Mar 24, 2019

Not something I plan to implement, but a PR for this will be considered

@ErikEJ ErikEJ closed this as completed Mar 24, 2019
@ErikEJ ErikEJ reopened this Aug 27, 2020
@ErikEJ ErikEJ added enhancement New feature or request help wanted Extra attention is needed reveng labels Aug 27, 2020
@Trigun27
Copy link

It will be a cool feature!

@ErikEJ
Copy link
Owner

ErikEJ commented Sep 24, 2020

@Trigun27 PRs accepted 😀

@Trigun27
Copy link

@ErikEJ Hi. I think this will be a nice feature. Maybe I can try to write the required code.
Any tips and suggestions?

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 12, 2020

Actually, it does not look like there is any way of doing the in a generic fashion with the current implementation.

This place would be a potential place to do it, but I am not sure you have any schema information at this point: https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/GUI/RevEng.Core/ReverseEngineerRunner.cs#L116

@ErikEJ ErikEJ removed the help wanted Extra attention is needed label Nov 21, 2020
@ErikEJ
Copy link
Owner

ErikEJ commented Dec 6, 2020

Closing as external, must be implemented in EF Core

@chassq
Copy link

chassq commented Feb 13, 2021

Thanks for re-opening this @ErikEJ !!

@ErikEJ
Copy link
Owner

ErikEJ commented Feb 27, 2021

I will have another look at this, could one of you outline the desired file structure?

Would it be something like:

.\Models
    Dbo
        Table1.cs
        Table2.cs
    Otherschema
        Table3.cs
        Table4.cs

@chassq
Copy link

chassq commented Feb 27, 2021

Hey @ErikEJ , See attached our current setup we do manually. Hope this helps. Our schema are named scAccess, for example, in the db. The "sc" prefix is just a naming convention we have to specify the db structure is a schema.

Screenshot 2021-02-27 032203

@stevie6410
Copy link

stevie6410 commented Apr 20, 2021

I will have another look at this, could one of you outline the desired file structure?

Hi @ErikEJ ,
This would be very useful. Is this still something which might yet be implemented?

@ErikEJ
Copy link
Owner

ErikEJ commented Apr 20, 2021

I am not really able to figure out how to do this without pulling in too much EF Core code, but I added this method recently, so maybe it is within reach: https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/GUI/RevEng.Core/ReverseEngineerScaffolder.cs#L227

A PR to do this would be considered!

@marcziss
Copy link

Hey Erik,
Thanks for an awesome toolkit, really makes my life much easier! As far as having multiple folders; I saw that the Handlebars project has support for that

services.AddHandlebarsScaffolding(options =>
{
    // Put Models into folders by DB Schema
    options.EnableSchemaFolders = true;
});

I assume that utilizing that mechanism won't work here because Reveng does it's own handling of the files and schemas?

@ErikEJ
Copy link
Owner

ErikEJ commented Apr 20, 2021

I guess the implementation could be used as inspiration?

@eminmesic
Copy link
Contributor

I took some time to investigate this part in the latest code, and I found that for the Stored Procedures and Functions it is easy to introduce this change, I can say few lines of change and I already did that locally for myself.

However, for the tables per the current code, it is not easy because EF Core Power Tools is referencing EF Core Scaffolding Generator, and for introducing this part we have to pull a lot of code from EF Core directly as @ErikEJ already said in the previous comments.

result.AdditionalFiles.Add(new ScaffoldedFile
{
    Code = classContent,
    Path = procedureScaffolderOptions.EnableSchemaFolders
            ? Path.Combine(procedure.Schema, $"{name}.cs")
            : $"{name}.cs"
});

@ErikEJ
Copy link
Owner

ErikEJ commented May 15, 2021

Fixed in #981 (Finally) - thanks @eminmesic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request reveng
Projects
None yet
Development

No branches or pull requests

7 participants