Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm running the dotnet code generator commands from C# (using Process class), I'm able to create project using dotnet new mvc and I'm also able to add nuget packages. But I'm not able to scaffold when application is running. Scaffold happens only when I stop solution.


Process p = getProcess();
p.Start();

p.StandardInput.WriteLine("cd C:\\Users");
p.StandardInput.WriteLine("mkdir " + projName);
p.StandardInput.WriteLine("cd " + projName);
p.StandardInput.WriteLine("dotnet new sln");

p.StandardInput.WriteLine("dotnet new mvc -n " + projName);
p.StandardInput.WriteLine("dotnet sln add .\\" + projName + ".\\" + projName + ".csproj");

p.StandardInput.WriteLine("cd " + projName);
p.StandardInput.WriteLine("dotnet add package Microsoft.EntityFrameworkCore.SqlServer");
p.StandardInput.WriteLine("dotnet add package Microsoft.EntityFrameworkCore.Tools");
p.StandardInput.WriteLine("dotnet add package Microsoft.EntityFrameworkCore.SqlServer.Design -v 1.1.6");
p.StandardInput.WriteLine("dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design");

p.StandardInput.WriteLine("dotnet add package bootstrap");

string connString = "Server = " + serverAddr + "; Database = " + dbName + "; Trusted_Connection = True;";               
p.StandardInput.WriteLine("dotnet ef dbcontext scaffold " + " 
            \"" + connString + "\" " + 
            "Microsoft.EntityFrameworkCore.SqlServer --output-dir Models 
             --project " + projName);


What I have tried:

p.StandardInput.Flush()
Posted
Updated 5-Aug-19 9:25am

1 solution

You can't scaffold while the app is running, because it would have to modify the project in order to complete said scaffolding.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900