I have a console app that auto generates C# classes and interfaces for a repository pattern based on poco entities which are auto generate using the Scaffold-DbContext command in the NuGet Package Manager Console w/in Visual Studio. In order to to automate the entire process of generating pocos and associated repositories and interfaces, I'd like to be able to call the Scaffold-DbContext command directly from the console app. Is it possible to call NuGet Package Manager Console commands outside of the native CLI?
Asked
Active
Viewed 1,369 times
5
-
I believe you can run all of the EF commands from the [migrate.exe](https://msdn.microsoft.com/en-us/library/jj618307(v=vs.113).aspx) tool. I could be wrong about that, though. If not, you could try [running the powershell command from cmd.exe](https://stackoverflow.com/q/2035193). Either one could be executed by invoking a new process within C#. – NightOwl888 Oct 06 '17 at 19:54
-
1Oops - I didn't notice you are using EF Core. migrate.exe won't work for you, but [this answer](https://stackoverflow.com/a/40675172/) or perhaps [this answer](https://stackoverflow.com/a/40476954) might pave the way. – NightOwl888 Oct 06 '17 at 19:58
-
As near as I can tell, those answers you linked to work for a migrate TO the database but not clear how to go the other direction. I have been unable to figure it out. But I gave you a vote because you're absolutely right that it could pave the way. – EGP May 11 '20 at 22:14