Secret storage in .NET

Enable secret storage:Type “dotnet user-secrets init” into Package Manager Console <UserSecretsId> can be found in .csproj file. Set a secret (Package Manager Console):dotnet user-secrets set “ApiKey” “test123” or to remove it:dotnet user-secrets remove “ApiKey” To check if exists:dotnet user-secrets listorManage secret through GUI -> right click on project -> Manage User Secrets -> it opensContinue reading “Secret storage in .NET”

The term ‘dotnet-ef’ is not recognized – Entity Framework error

Quick post about fixing Entity Framework, probably common error when you want to use ef for the first time e.g. you installed Visual Studio on new pc, fresh os, new project etc. and want to make dotnet-ef migrations or database update. Error message:“dotnet-ef : The term ‘dotnet-ef’ is not recognized as the name of aContinue reading “The term ‘dotnet-ef’ is not recognized – Entity Framework error”

Scaffolding in .NET Core (generate API controllers – CRUD (or MVC controller with views in necessary)

Right click on ‘Controllers’ folder –> Add –> New Scaffolded Item… For api controller without views select ‘API Controller with actions, using Entity Framework’ and click ‘Add’.If MVC then choose ‘MVC Controller with views, using using Entity Framework’ On next view select your model (you need create model before generate code) and select data contextContinue reading “Scaffolding in .NET Core (generate API controllers – CRUD (or MVC controller with views in necessary)”

Background automation tasks in .NET Core – sample web application using Hangfire

It is the second post about Hangfire, but this time I am using Hangfire in web application. And there is link to previous post about Hanfire in console application:Background automation tasks in .NET – sample console application using Hangfire I will show a simple web application using Hangfire to automate tasks. First, create a new project:Continue reading “Background automation tasks in .NET Core – sample web application using Hangfire”

Get data from appsettings.json file

I will show how to get your data from appsettings.json and e.g. show it on view. First, go to an appsettings.json and add the entry. In my case, I added:“Message”: “Message from appsettings.json” All appsettings.json code looks like this: Second step, changes to the controller, let’s take a sample HomeController. So inject IConfiguration in HomeControllerContinue reading “Get data from appsettings.json file”

Background automation tasks in .NET Core – sample console application using Hangfire

I will show a simple console application using Hangfire to automate tasks. First, create a new project: Console App (.NET Core). In my case netcoreapp3.1: Install Hangfire – add packages:Hangfire.CoreHangfire.SqlServer Copy the following code to the Main method: We also need to add namespaces: And the last step, create a database. Go to SSMS andContinue reading “Background automation tasks in .NET Core – sample console application using Hangfire”

Git clone fatal: Authentication failed

I recently had a problem with git credentials on Windows and a message like “git clone fatal: Authentication failed for…” Git did not work because the old password was set. In order for git to work again, I had to change the password in Windows settings. To fix this, go to the following path: AndContinue reading “Git clone fatal: Authentication failed”