Hi,
I need to do scaffolding in code. To do this I wrote this method;
The string value that I send to the method is;
It returns this message;
But when I apply "dotnet build" command in powershell there is no errors at all. This command works when I use it in the powershell screen manually.
Is the something that I miss in the Runscript Method?
Note: I used oracle database in this sample but MsSql also gives the same result.
Thank you.
I need to do scaffolding in code. To do this I wrote this method;
RunScript Method:
public string RunScript(string scriptText)
{
string dir = @"C:\Users\demetsen\source\repos\ScaffoldingInCode\ScaffoldingInCode";
Directory.SetCurrentDirectory(dir);
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(scriptText);
Collection<PSObject> results = pipeline.Invoke();
runspace.Close();
StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.ToString());
}
return stringBuilder.ToString();
}
The string value that I send to the method is;
scriptText:
string scriptText = "dotnet ef dbcontext scaffold \"Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE))); User Id = ***;Password=***;\" Oracle.EntityFrameworkCore --context-dir Data --output-dir Models --context ModelContext -f;";
It returns this message;
result:
Build started...
Build failed. Use dotnet build to see the errors.
But when I apply "dotnet build" command in powershell there is no errors at all. This command works when I use it in the powershell screen manually.
Is the something that I miss in the Runscript Method?
Note: I used oracle database in this sample but MsSql also gives the same result.
Thank you.