dotnet ef dbcontext scaffold is not wokring in vs2019 - asp.net-core-webapi

In my ASP.NET Core (V 3.1) WebAPI project, I've the following Nuget packages
Microsoft.EntityFrameworkCore 5.0.4
Microsoft.EntityFrameworkCore.SqlServer 5.0.4
Microsoft.EntityFrameworkCore.Tools 5.0.4
I'm trying to create models as follows-
dotnet ef dbcontext scaffold "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=SafeSave;Integrated Security=True;Pooling=False;" Microsoft.EntityFrameworkCore.SqlServer -o Models
But the above command does not create any thing.
What did I miss here?

Firstly, you can try to use the following command to install the latest dotnet ef as a global tool.
dotnet tool install --global dotnet-ef
And please ensure you install this package Microsoft.EntityFrameworkCore.Design that is required for the Entity Framework Core Tools to work.
Then clear and rebuild your project, and re-run and retry your command to create models.
dotnet ef dbcontext scaffold "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=SafeSave;Integrated Security=True;Pooling=False;" Microsoft.EntityFrameworkCore.SqlServer -o Models

Related

dotnet entity frameworkcore migration command not work in vs 2022

While migration in ef core using below command give me an error.
dotnet tool install --global dotnet-ef
After refer this link , i have executed below command.
dotnet tool install --global dotnet-ef
But still give me an error.
Below packages installed in my project.
Microsoft.EntityFrameworkCore(3.1.25) ,
Microsoft.EntityFrameworkCore.Design(3.1.25),
Microsoft.EntityFrameworkCore.SqlServer(3.1.25),
Microsoft.EntityFrameworkCore.Tools(3.1.25)
For the migrations command you need to install the Microsoft.EntityFrameworkCore.Tools Nuget package.

DotNet Nuget pushing same package version without warning

I have a command that runs after release build.
dotnet nuget push Test.nupkg -s \\Path
I am using Dotnet version
6.0.200
and nuget version
6.1.0.103
In the older version of dotnet (2.1) I used to get a error when pushing duplicate version like this
warning MSB3073: The command "dotnet nuget push "***" exited with code 1.
Is there a way to avoid pushing duplicate in 6.0.200 ?

dotnet-ef still not found after installation

I installed the dotnet-ef tool on a Ubuntu server, and it installed successfully. However, the program was still not found:
~/app$ dotnet --version
3.1.201
~/app$ dotnet tool install --global dotnet-ef --version 3.1.3
Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.
You can invoke the tool using the following command: dotnet-ef
Tool 'dotnet-ef' (version '3.1.3') was successfully installed.
After rebooting the server:
~/app$ dotnet-ef migrations add "First On Server"
dotnet-ef: command not found
~/app$ which dotnet
/usr/bin/dotnet
~/app$ which dotnet-ef
~/app$
How do I get the dotnet-ef tool on a Ubuntu machine?
The dotnet tool install command requires elevation!

Running dotnet core application (dll) without SDK

I'm trying to get my dotnet Core application running on an ubuntu 18.04LTS machine with dotnet core runtime installed.
The command:
dotnet myapp.dll
The result:
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
As far as I understand I do not need the SDK for simply running this application. Just the runtime should suffice, right?
dotnet --info
Host (useful for support):
Version: 2.2.8
Commit: b9aa1abc51
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
How to make this work without installing an SDK?
It actually worked. I was running the dotnet command with the wrong path.. myapp.dll was nested a bit deeper. My mistake.

Dotnet aspnet -codegenerator failed for dotnet core 3.1

I followed https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.1&tabs=visual-studio-code and run
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet aspnet-codegenerator razorpage -m Movie -dc RazorPagesMovieContext -udl -outDir Pages\Movies --referenceScriptLibraries
After that, I got error
Building project ...
Scaffolding failed.
Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
To see more information, enable tracing by setting environment variable 'codegen_trace' = 1.
RunTime 00:00:03.47
I try to add package using
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design --version 3.1.0
and Get error
Writing C:\Users\tdong.BCFSA\AppData\Local\Temp\tmpA5E0.tmp
info : Adding PackageReference for package 'Microsoft.VisualStudio.Web.CodeGeneration.Design' into
project 'D:\Work\Testing\Movies\RazorPagesMovie\RazorPagesMovie.csproj'.
info : Restoring packages for D:\Work\Testing\Movies\RazorPagesMovie\RazorPagesMovie.csproj...
error: Package NuGet.Frameworks 4.7.0 is not compatible with netcoreapp3.1
(.NETCoreApp,Version=v3.1). Package NuGet.Frameworks 4.7.0 does not support any target frameworks.
error: Package 'Microsoft.VisualStudio.Web.CodeGeneration.Design' is incompatible with 'all'
frameworks in project 'D:\Work\Testing\Movies\RazorPagesMovie\RazorPagesMovie.csproj'.

Resources