Search code examples
asp.net-mvcasp.net-mvc-3powershellasp.net-mvc-scaffolding

MVC Scaffolding: Is there a Windows PowerShell Command to switch project in a solution?


I am writing a scaffolder to create classes automatically in an ASP.Net MVC 3 project. However, my solution contains four projects (MyProject.Domain, MyProject.Data, MyProject.Services and MyProject.Web), and at some point in the scaffolder, I would need to switch project programatically. Is there a way to do that? This is, I guess, the same thing as asking whether there is a Windows PowerShell command to witch default project.

In case this helps to understand, here is what I want to do. I want to launch the scaffolder from MyProject.Web to create a Controller and Views, and I would like the scaffolder to also have the ability to create the repository and the service for the model I specify. However, the repository class and the service class should go in different projects (MyProject.Data and MyProject.Services).

UPDATE:

Another way of asking the question is: If I call a scaffolder in MyProject.Web, can this scaffolder call another scaffolder in MyProject.Data for example? MyProject.Web and MyProject.Data being two projects in the same solution.


Solution

  • I just found out that the Scaffold command has a -P option to specify the project, so this would solve my problem. A scaffolder called from MyProject.Web, could call Scaffold Repository -P "MyProject.Data" SomeModel