EFCorePowerTools icon indicating copy to clipboard operation
EFCorePowerTools copied to clipboard

Feature Request: Place sproc Entities in same place as other Entities

Open bmainsteleo opened this issue 3 years ago • 11 comments

As a feature request, it would be great to be able to support Handlebars as the means to generate the StoredProcedures class that contains all the SP methods, as well as the ability to use Handlebars to customize the entities that are generated.

It would also be helpful if the entities for the SP can go in a different project than the main context too, like you can do for the entities representing the table.

bmainsteleo avatar Feb 28 '22 14:02 bmainsteleo

Have you tried the built in support for this?

ErikEJ avatar Feb 28 '22 14:02 ErikEJ

I haven't tried anything other than EF Core Power Tools approach because I wasn't sure what was possible...

bmainsteleo avatar Feb 28 '22 14:02 bmainsteleo

Handlebars is not possible.

What customizations are you looking for in your result classes?

Asking for classes to be placed together with the Entity classes seems like a valid feature proposal.

ErikEJ avatar Feb 28 '22 15:02 ErikEJ

Mostly I would love to have all of the entities together in one place. Also, if the SP entities could use the same handlebar as the Table-based entities, that would be great.

bmainsteleo avatar Feb 28 '22 18:02 bmainsteleo

As I and Tony wrote Handlebars is not an option.

Could we rename this to: Place sproc Entities in same place as other Entities?

ErikEJ avatar Feb 28 '22 19:02 ErikEJ

Sure, thanks.

bmainsteleo avatar Feb 28 '22 19:02 bmainsteleo

@bmainsteleo Looks to me like this already works as expected - the Result classes are placed in same folder as all other models, and the ProcedureContext is place with the DbContext.

ErikEJ avatar Mar 06 '22 12:03 ErikEJ

@ErikEJ The steps we took were:

  • Created a project: Demo.Persistence, and reverse engineered with the following settings:
    • Entity Types Sub-namespace: "Entities"
    • What to generate: DbContext Only
    • Naming > Pluralize or singularize.. checked
    • Customize code using Handlebars: C#
    • Advanced > File Layout > Split DbContext into configuration classes
  • Created a project: Demo.Persistence.Entities, and reverse engineered with the following settings:
    • EntityTypes path: Entities
    • What to generate: EntityTypes only
    • Naming > Pluralize or singularize.. checked
    • Customize code using Handlebars: C#

To start, we only chose a few tables. Later on, we eventually added the SP's... so we didn't just start with every SP in the model. If you generate SP's after initially creating the model, do you get the same behavior?

For me, generating SPs later yields all of these changes in Demo.persistence:

  • DemoContextProcedures.cs
  • spGetAllCustomers.cs
  • spGetAllOrders.cs

and so on. Nothing is in Demo.Persistence.Entities.

bmainsteleo avatar Mar 07 '22 11:03 bmainsteleo

Ah, I tested using project folders not multiple projects.

ErikEJ avatar Mar 07 '22 11:03 ErikEJ

@bmainsteleo Looks to me like this already works as expected - the Result classes are placed in same folder as all other models, and the ProcedureContext is place with the DbContext.

@ErikEJ : i can confirm that it definitively works fine from this perspective

CorsairRO avatar Apr 07 '22 08:04 CorsairRO

@CorsairRO what settings are you using because I just tried it, and it is still putting the EF Stored Procedure Result Classes in the Db Context project for me, not the Entity Classes project.... Am I missing a setting somewhere?

cc: @ErikEJ

bmainsteleo avatar Apr 07 '22 11:04 bmainsteleo

No current plans to support this.

ErikEJ avatar Sep 07 '22 09:09 ErikEJ