Where's NuGet manager console in Rider IDE? - rider

I am new to .NET platform. From time to time, I had problems with Visual Studio and I decided to use Rider. It encouraged me again (I have been using JetBrains products for 2 years). But I can not find the NuGet console (which is so called in Visual Studio).
Where is it?

It's not accessible yet. Please vote this issue https://youtrack.jetbrains.com/issue/RIDER-435

It is available since Rider 2018.1.
Please see JetBrains' blog post about installation: https://blog.jetbrains.com/dotnet/2018/04/06/entity-framework-support-rider-2018-1/
P.S. tested on Rider 2020.2.1.

You Can use PowerShell on Windows "Where Your DbContext is" Like this:
dotnet ef
dotnet ef migrations add [Name]

If you need to run entity framework commands such as
dotnet ef migrations add "initialSetup"
Then go to your terminal Alt+f12 or double-shift and type “terminal”.
Then run:
dotnet tool install --global dotnet-ef
And then (making sure you're in your project directory):
dotnet ef migrations add "initialSetup"

Although Rider has now added the UI for migration, unfortunately, if you use the latest dotnet feature the UI doesn't work.
For example, I created the project without Startup class file, the UI won't let me continue:
But I tried these commands which works:
dotnet tool install --global dotnet-ef
# You can type the DbContext manually now!
dotnet ef migrations add 'initial' --project src/IdentityServer/IdentityServer.csproj --context PersistedGrantDbContext
Then I execute:
dotnet ef database update --project src/IdentityServer/IdentityServer.csproj --context ConfigurationDbContext
Now the database updated with all the tables there:

They haven't implemented the Package manager console yet. So you will have to use Visual studio for that

You can use terminal toolwindow. Or NuGet manager (GUI)...

Related

Creating classes from Postgres database for Entity Framework Core

Looking for a method to automatically create entity classes from existing Postgres 13 database.
in
According to
http://www.npgsql.org/efcore/index.html
In Visual Studio 2019 command prompt
dotnet ef dbcontext scaffold "Host=my_host;Database=my_db;Username=my_user;Password=my_pw" Npgsql.EntityFrameworkCore.PostgreSQL
Command should do this but it throws error
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
NpgSql.EntityFrameworkCore.PostgreSQL v5.0.1 package is installed from Nuget.
You should install Dotnet EF tool.
try this in your package manager console
dotnet tool install --global dotnet-ef
After that it is recommended to install design tool aswell so you can use tools on specific project
dotnet add package Microsoft.EntityFrameworkCore.Design

In ASP.NET MVC Core, what do the Microsoft.AspNetCore.Razor.Design and Microsoft.VisualStudio.Web.CodeGeneration.Design packages do?

Are they only needed at design time? Can they be removed without causing any build issues? (Targeting framework netcoreapp2.1).
The package of Microsoft.AspNetCore.Razor.Design contains MSBuild support for Razor. If you're developing an asp.net core app, there's no need to add an package reference on Microsoft.AspNetCore.Razor.Design manually (and also you're not supposed to remove them manually). Because it is referenced by Microsoft.AspNetCore.App meta package, which means if you have a dependency on Microsoft.AspNetCore.App, you'll reference the package automatically.
The package of Microsoft.VisualStudio.Web.CodeGeneration.Design is a quite different one. As the name suggests, it is used to generate codes only. For example, you want to develop a project without Visual Studio:
You create a new project using the command of dotnet new mvc
And then you create a new Model named App.Models.MyModel mannually
Typically, we'll use Visual Studio to generate controllers, views, DbContext and so on. But what if we don't have Visual Studio?
If we have the Microsoft.VisualStudio.Web.CodeGeneration.Design referenced in our *.csproj file, we can create the CRUD scaffold using the following command :
dotnet aspnet-codegenerator controller -m $model -dc $dcClass -name $controllerName -namespace $controllerNamespace -outDir Controllers --useDefaultLayout
There're also some other sub commands such as :
dotnet aspnet-codegenerator identity -dc $dcClass
However, this package is only used to scaffold. Once you have the codes generated, you can feel free to remove this package before publish.
As a side note, to use the dotnet aspnet-codegenerator command, we should first install the tool:
dotnet tool install --global dotnet-aspnet-codegenerator

.NET Standard and TFS 2015 -> Build failures

My infrastructure now has TFS 2015, but we started a new project in .NET Standard. Our build server now has VS2017, and the project builds when loaded within VS2017 in that server.
When we set a new build definition to run the build through the build agent, then it fails. Seems even that System is not found:
Error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
Is there any simple thing to do to make it work, ir we will have to migrate to the new build steps to make it work? Some workaround?
I find a workaround for that. Simply I gave up of using the TFS 2015 build steps MSBUILD and Visual Studio Build, and now I am using the Command Line step. Calling the commands from there:
dotnet restore
dotnet build
That does the trick.
This is because we need to do our restore a different way using the .net core restore. You could fix this by adding the .NET Core (PREVIEW) task to the build definition or just use command line task. With command line task could running dotnet restore, dotnet build, dotnet publish, and dotnet test.
More details please take a look at this blog: Setting up .net core continuous integration build with VSTS/TFS
For command line solution please refer vsts-agent Build Definition for .NET Core (with Test Results) Also take a look at this similar question: Visual studio team services build .net core 1.1

How To Enable Migration in .net Core?

Enable-Migrations -ProjectName SampleApplication -ContextTypeName MyDbContext
I have given the above command but it's not working?
To Enable Migration Which Command need to Apply?
Migrations are enabled by default in EF Core but you have to install
Microsoft.EntityFrameworkCore.Tools
nuget package.
It looks like that package isn't installed by default with EF Core.
With EFCore you do not need to "enable" migrations - they are always-enabled. Just add new migration with Add-Migration.
Documentation about package manager commands is here

Did `dnu restore` replaced `dotnet restore` on yeoman generator-aspnet?

I have ASP.NET Core (v1.0.0-preview2-003131) installed on my macOS Sierra, and installed yeoman generator-aspnet today(11/26/16). From my cli, I ran yo aspnet and created my WebApplication but the options shown to use were dnu restore, dnu build, dnx . kestrel.
What happened to dotnet restore option? I even tried to run dotnet restore but it kept on looking for dnu.
No, DNU is part of the old DNX which was used up until rc1. RC2 and newer are based on dotnet-cli and the dotnet commands.
DNX isn't maintained anymore and shouldn't be use anymore. Just use the dotnet commands, ignoring what that generator says and report the issue here.