I have a ASP.Net Core project where I have been trying to scaffold an existing database to create a dbcontext. This is the project.json file:
{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
}
},
"frameworks": {
"net452": { }
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Microsoft.EntityFrameworkCore.Tools is "preview1 final", but I don't see any newer version, like rc2, that I could use... I had installed various different dependencies before getting to the current state, but I had executed dotnet tool to rebuild the whole project and even used the mysterious --infer-runtimes option mentioned in some answers. Still no luck.
I have PowerShell 5.0 on the machine:
PS C:\projectfolder> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 117
When running dotnet ef command in PowerShell, when in the project's folder, I am getting the following error (I replaced project name and path with "projectfolder" here). The same happens if I use the "scaffold" ef command, so here is just the simplest form of the command line to get the error:
PS C:\projectfolder> dotnet --verbose ef --help
[...]
Running C:\projectfolder\bin\Debug\net452\win7-x86\Microsoft.EntityFrameworkCore.Tools.Cli.exe --framework net452 --configuration Debug --verbose --help --dispatcher-version 1.0.0-preview1-20901
System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Microsoft.DotNet.Cli.Utils.Command.Execute()
at Microsoft.EntityFrameworkCore.Tools.DispatchCommand.<>c__DisplayClass2_0.<Create>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
dotnet --info returns:
.NET Command Line Tools (1.0.0-preview1-002702)
Product Information:
Version: 1.0.0-preview1-002702
Commit Sha: 6cde21225e
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x86
The system is win7 32bit. The .Net frameworks installed on this system are:
- Core 1.0.0 RC2 - SDK Preview 1 (x86)
- Core 1.0.0 RC2 - VS 2015 Tooling Preview 1
- 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1
Update: I have also checked (again) whether it works from the VS Package Manager's command line, but (as expected I guess) it fails with the same error message:
PM> Scaffold-DbContext -Connection 'Server=name;Database=testdb;Persist Security Info=False;User ID=user;Password=pass' -Provider Microsoft.EntityFrameworkCore.SqlServer -Verbose
Working directory: C:\projectfolder
Executing command: dotnet ef --configuration Debug --build-base-path .\bin\ dbcontext scaffold 'Server=name;Database=testdb;Persist Security Info=False;User ID=user;Password=pass' Microsoft.EntityFrameworkCore.SqlServer --verbose
System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform. at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Microsoft.DotNet.Cli.Utils.Command.Execute()
at Microsoft.EntityFrameworkCore.Tools.DispatchCommand.<>c__DisplayClass2_0.<Create>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
The specified executable is not a valid application for this OS platform.
Update: I have added "Microsoft.EntityFrameworkCore" to project dependencies, but no difference. (I guess that assembly was already present, as a dependency of the others...)
What am I doing wrong?* Help... Is there anything else I should be installing/checking?