Following this tutorial it is possible to scaffold a database context using Entity Framework Core via the command line.
Scaffolding has some strange requirements
- it needs an entry point aka main method (no scaffolding into class libraries)
- the complete project has to be compileable (before scaffolding)
In my current project I need the model classes in a "shared project" (not directly a class library). The shared project does not have an entry point.
(I currently scaffold a lot since DB engineer updates the database model a lot in a database first approach).
In order to create some automated scaffolding task script I planed to automate the following tasks:
- create a new, empty & temporay dot net command line application (it is buildable and has an entry point)
- add required packages
- scaffold the database context and model classes
- move the generated classes to the library/shared project
- delete the temporary project
So far I managed to automate the first points.
But I can't figure out a way how to add the ItemGroup DotNetCliToolReference to the xml of the .csproj file.
Is there any dotnet cli command that lets me add the DotNetCliToolReference and not only packages and project-to-project references?
Any other hints for me, please?