No executable found matching command "dotnet-ef" (csproj) vs2017 - entity-framework

I try to do https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/complex-data-model
When I execute dotnet ef migrations add ColumnFirstName error appears
I installed many packages via Install-Package but error appears.
Here is my csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
I add
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
and that solved.

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>

Related

.NET MAUI app crashing because it's not loading image file

In my .NET MAUI app, I changed the icons used by the app from font based icons to PNG files and I store these images in Resources > Images folder.
I was able to successfully create a package and upload it to TestFlight but when I try to open the app, it crashes immediately. In crash logs, I see that the cause of crash is that the app was unable to load the PNG file I use for the Flyout i.e. the hamburger menu icon.
The other key change in the app is that it's now a .NET 7 based app.
I thought the publish process would add the PNG images used by the app to the ipa package if I placed them in Resources > Images folder.
Any idea what could be the issue here?
Here are screenshots of exception logs
And here's the MyApp.csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>MyApp</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>MyApp</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.mycompany.myapp</ApplicationId>
<ApplicationIdGuid>0636ab8b-e4f3-4c11-83e5-b809594a10b5</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.2</ApplicationDisplayVersion>
<ApplicationVersion>68</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net7.0-ios'">
<CodesignKey>Apple Development: Samuel Uresin (3YQ4LF4U5J)</CodesignKey>
<CodesignProvision>VS: llc.iquest.ingrid.connect Development</CodesignProvision>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.png" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.png" Color="#262627" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Images\about_graphite.png" />
<None Remove="Resources\Images\badge_graphite.png" />
<None Remove="Resources\Images\biz_profile_graphite.png" />
<None Remove="Resources\Images\coupons_graphite.png" />
<None Remove="Resources\Images\customers_graphite.png" />
<None Remove="Resources\Images\dashboard_graphite.png" />
<None Remove="Resources\Images\feed_graphite.png" />
<None Remove="Resources\Images\hamburger_manu_graphite.png" />
<None Remove="Resources\Images\intercom_graphite.png" />
<None Remove="Resources\Images\plus_graphite.png" />
<None Remove="Resources\Images\power_graphite.png" />
<None Remove="Resources\Images\qr_scan_graphite.png" />
<None Remove="Resources\Images\qr_scan_large_graphite.png" />
<None Remove="Resources\Images\search_graphite.png" />
<None Remove="Resources\Images\settings_graphite.png" />
<None Remove="Resources\Images\shop_graphite.png" />
<None Remove="Resources\Images\single_user_graphite.png" />
<None Remove="Resources\Images\subscriptions_graphite.png" />
<None Remove="Resources\Images\user_profile_graphite.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="3.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Ingrid.Aurora" Version="1.5.1" />
<PackageReference Include="Ingrid.Core" Version="1.5.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="MonkeyCache.FileStore" Version="1.6.3" />
<PackageReference Include="Plugin.InAppBilling" Version="6.7.0" />
<PackageReference Include="Plugin.Maui.Audio" Version="0.1.0-preview1" />
<PackageReference Include="Sentry.Maui" Version="3.23.1-preview.3" />
<PackageReference Include="Syncfusion.Maui.Barcode" Version="20.3.56" />
<PackageReference Include="ZXing.Net.Maui.Controls" Version="0.2.0-preview.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="SQLitePCLRaw.core" Version="2.1.0" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.0" />
<PackageReference Include="SQLitePCLRaw.provider.dynamic_cdecl" Version="2.1.0" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.0" />
</ItemGroup>
</Project>
I was setting the Flyout icon in Styles.xaml and this was the issue -- see below.
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.FlyoutIcon" Value="mymenuicon.png" />
</Style>
There's probably a way to set it in Styles.xaml and I'd appreciate it if someone can show me how to do that in the comments.
The fix for my problem was simply setting it in AppShell as follows:
<Shell
x:Class="MyApp.AppShell"
FlyoutIcon="mymenuicon.png">
...
</Shell>

Exception when Scaffold-DbContext with IBM.EntityFramework

When using the command in the package manager console window in VS2017 Professional
Scaffold-DbContext "server=server;uid=username;pwd=password;database=database" IBM.EntityFrameworkCore -force
With these dependencies:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IBM.EntityFrameworkCore" Version="1.3.0.100" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.4" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
I'm encountering the following exception:
System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpDbContextGenerator..ctor(Microsoft.EntityFrameworkCore.Scaffolding.IScaffoldingProviderCodeGenerator, Microsoft.EntityFrameworkCore.Design.IAnnotationCodeGenerator, Microsoft.EntityFrameworkCore.Scaffolding.Internal.ICSharpUtilities)'.
at IBM.EntityFrameworkCore.Scaffolding.Internal.Db2CSharpDbContextGenerator..ctor(IScaffoldingProviderCodeGenerator providerCodeGenerator, IAnnotationCodeGenerator annotationCodeGenerator, ICSharpUtilities cSharpUtilities)
It should be noted that there is another project in the same solution also using EntityFramework Core for SQL Server that is generating the DB Context fine with the Scaffold-DbContext command.

Script-Migration' is not recognized as the name of a cmdlet,

I am using EF core migration Visual Studio 2017 update 2 and latest asp.net core 1.1
My csproj
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
I am able to run the command
Add-Migration
in my package manager console
However I am not able to run the command
Script-Migration
as I get the error message
Script-Migration' is not recognized as the name of a cmdlet
After upgrading from Entity Framework Core 1.1. to Entity Framework Core 2.0 I can access the command.

Visual Studio 2017 mistakenly thinks EF 6 is installed

I upgraded my ASP.NET Core, EF Core class library solution to Visual Studio 2017.
However when I want to run migrations commands like Add-Migration I get the following warning.
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Update-Database' for Entity Framework 6.
However I don't have EF 6 installed
My csproj
...
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Linq" Version="4.3.0" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>
This can happen if you previously had an EF6 project open in VS. To unload EF6, you can use the following command.
Remove-Module EntityFramework

Unable to generate model from database in Visual Studio 2017 RC

I followed the official Microsoft tutorial for Entity Framework Core database first approach available in this link.
When I try to execute the below command to generate the model from the database:
Scaffold-DbContext "Server=Data Source=DESKTOP-COJD62N;Initial Catalog=TrainGameDB;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -context TrainGameContext -Verbose
I am getting the following output:
Build started...
Build succeeded.
dotnet exec needs a managed .dll or .exe extension. The application specified was 'F:_IIT Level 6\UX\CW2 Backend\App2\TrainGameAPI\src\TrainGameAPI\bin\Debug\netcoreapp1.0\TrainGameAPI.runtimeconfig.json'
Process finished with non-zero exit code
I am using:
Visual Studio 2017 RC
SQL Server 2016 Developer
.NET Core 1.1.0 (I uninstalled version 1.0.1 and installed this)
ASP.NET Core Web API Application
Windows 10 Education
Here is the list of packages from my .csproj file (VS 2017 doesn't have a package.json file)
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.0" />