what is the target platform of the build? and does it match the environment you are running the migrate from.
Exception calling "Start" with "1" argument(s): "The specified executable is not a valid application for this OS platform." with all ef core commands
When I run one of the ef core commands, I encounter the following error:
Exception calling "Start" with "1" argument(s): "The specified executable is not a valid application for this OS platform." At line:1 char:1
For example:
PM> Update-Database -Context ContentServiceCommandDbContext Build started... Build succeeded. Update-Database : Exception calling "Start" with "1" argument(s): "The specified executable is not a valid application for this OS platform." At line:1 char:1
- Update-Database -Context ContentServiceCommandDbContext
+ CategoryInfo : NotSpecified: (:) [Update-Database], MethodInvocationException + FullyQualifiedErrorId : Win32Exception,Update-Database
or
PM> Add-Migration ChangeSomething -Context ContentServiceCommandDbContext Build started... Build succeeded. Add-Migration : Exception calling "Start" with "1" argument(s): "The specified executable is not a valid application for this OS platform." At line:1 char:1
- Add-Migration ChangeSomething -Context ContentServiceCommandDbContext
+ CategoryInfo : NotSpecified: (:) [Add-Migration], MethodInvocationException + FullyQualifiedErrorId : Win32Exception,Add-Migration
and so on ...
There is a problem and it has nothing to do with version 8 or 9 of EF Core.
As you can see in the image, there is also the dotnet environment variable.
2 answers
Sort by: Most helpful
-
-
Hongrui Yu-MSFT 3,165 Reputation points Microsoft Vendor
2024-11-27T09:58:33.98+00:00 Hi,@Arman Espiar. Welcome to Microsoft Q&A.
Judging from the current situation, this seems to be related to your environment. You could try the following methods. Method 1 Configure environment variables correctly: In Visual Studio 2022, open Terminal (View->Terminal) and run the
dotnet --version
command. If the .Net version could be successfully output, the environment variable configuration is successful. Of course, you could also delete the dotnet file inC:\Program Files
, then re-download dotnet and install it. By default, it will automatically configure the dotnet operating environment for you.Reinstall Entity Framework Core related packages: Find Entity Framework Core related packages in
C:\Users\{UserName}\.nuget\packages
, delete them, and re-download them through NugetMethod 2 Execute Code First commands in
.Net Core CLI
Run commands in Terminal(View->Terminal)dotnet ef migrations add ChangeSomething
dotnet ef database update
Related Documents: Migrations Overview - EF Core | Microsoft Learn
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.