ErikEJ/EFCorePowerTools

Possible to use T4 to change the access modifier on the DbContext partial for the Stored Procedure generated code?

GET-Paul opened this issue · 4 comments

I've just reverse engineered a stored procedure for the first time and am wondering if we can use T4 to change the access modifier on the generated partial DbContext class?

Our DbContext T4 generates internal partials, however the generated code for the inclusion of stored procedures is public and I have to manually edit the file to the below after any refresh. It won't be such a pain once the rapid development phase is over, but with everything else being so perfect with the tools it really sticks out!

    internal partial class MyContext
    {
        private IMyContextProcedures _procedures;

        public virtual IMyContextProcedures Procedures ...

        public IMyContextProcedures GetProcedures() ...
    }

The stored procedure generated code is not under T4 control. You can add a postrun.cmd file to do the replacements after each run of the tool.

Thanks. Found the mention of that in the wiki now. Any pointers on the syntax of the file? It's an area I'm entirely unfamiliar with.

It is just a windows .cmd file, you can put anything you want inside. Call a powershell script or an console app to do the replacements

If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship