Cannot load PowerShell snap-in Microsoft.PowerShell.Diagnostics

demetsen

Member
Joined
Jan 24, 2022
Messages
14
Programming Experience
1-3
Hi,

I need to run powershell command in C# code for a scaffolding. This is a .NET Entity Framework Core Console project. I will take a Database string from a user and use DB First Method to link the database. Is this possible to do this?

This is my code:
1643034323934.png

1643034585772.png



This is the output that I get:
1643034084776.png


Thank you.
 

Attachments

  • 1643034273963.png
    1643034273963.png
    137.5 KB · Views: 35
Last edited:
Which file or assembly can't be loaded?
What is the C# project platform?
 
Thanks for updating post to include information. I see there is netcoreapp3.1 in your path. From what I can tell the Microsoft.PowerShell.SDK 7.2.1 depends on .Net 6. The last version that supports .Net Core 3.1 looks to be 7.0.8.
 
As a quick aside, in the future please post your code as text in code tags instead of using screenshots.

This doesn't look like database issue. It looks like a PowerShell hosting issue.
 
Thanks for updating post to include information. I see there is netcoreapp3.1 in your path. From what I can tell the Microsoft.PowerShell.SDK 7.2.1 depends on .Net 6. The last version that supports .Net Core 3.1 looks to be 7.0.8.
Thanks a lot for your response.
I updated package versions like this and it worked:

1643093911023.png


But this time it gives this error:
1643093991812.png


"Scaffold-DbContext" command is working when do this manually with Packace Manager Console.

Scaffold-DbContext "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE))); User Id =***;Password=***;" Oracle.EntityFrameworkCore -contextdir Data -OutputDir Models -context ModelContext -Force;

Is there something that I am missing?
 
Are you running VS/your app as elevated administrator?
 
Maybe someone that knows Oracle EF Core can see the problem. Feel free to post a separate thread about this issue in Entity Framework or Oracle
 
Back
Top Bottom