As technology evolves and we progress as a community, I notice that older blog posts erode in their helpfulness. One of the topics I find myself constantly having to relearn, especially as an OSS author, is the ability to start a new project, build a continuous integration pipeline, and get my package to NuGet. It’s essential to understand how to design a workflow that works with your project, and in this post, we’ll take a step-by-step walkthrough of how to do just that.
In this post we'll go through the steps to connect a .NET API to MySQL using Entity Framework Core, and to create a MySQL database from code using EF Core migrations. We'll start with an example .NET CRUD API from a tutorial I posted recently, it uses an EF Core InMemory database by default for testing, we'll update it to connect to a MySQL database and run EF Core migrations to auto generate the database and tables from code. For full details about the .NET CRUD API see .NET 5.0 - CRUD API Example and Tutorial.
In the previous article I demonstrated how we can write our log in our dotnet applications into Elastic with NLog, if you haven't read that article, I highly recommend reading it first.
The first question definitely comes in mind, why use multiple databases ? Well it is good to have database vendor independent backend so that you can swap it out whenever it is required. Or you may have a client who wants their data in a particular database vendor. That’s where ORM comes into picture. ORM like Entity-Framework allows you to talk to multiple database with ease. This article is about using Entity Framework to achieve this and I can say it is very very simple. Shall we start ? Here we taking SQL Server and Postgres DB as an example.
In this article we will learn about the Hangfire — .Net Library to make our background tasks and jobs easier in ASP.NET 5.0. As we all know, its newly launched Framework officially released in November. Here I am sharing the link to install the SDK for .Net 5
In this article, I'm going to use NLog to write my .Net 5.0 web application logs into Elastic. after that, I will show you how you can monitor and search your logs with different filters by Kibana.
Bing runs one of the world’s largest, most complex, highly performant, and reliable .NET applications. This post discusses the journey and the work required to upgrade to .NET 5, including the significant performance gains we achieved.This application sits in the middle of the Bing architecture...
In this tutorial we'll go through an example of how to implement JWT (JSON Web Token) authentication with refresh tokens in a .NET 5.0 API. Authentication is implemented with JWT access tokens and refresh tokens. On successful authentication the API returns a short lived JWT access token that expires after 15 minutes, and a refresh token that expires after 7 days in an HTTP Only cookie. The JWT is used for accessing secure routes on the API and the refresh token is used for generating new JWT access tokens when (or just before) they expire.
This is a quick post to show how to implement a global exception handler in .NET 5.0. These are the main pieces involved in the error handling process that we'll cover in this tutorial: Global Error Handler Middleware - custom middleware that catches all exceptions and determines...
This is a quick post to show how to configure a .NET 5.0 API to allow CORS requests from any origin as well as with credentials. I received the following error after setting credentials: 'include' for CORS requests sent from a React app to a .NET 5.0 API running on a different domain, and configuring CORS on the API to .AllowAnyOrigin() and .AllowCredentials().
In this tutorial we'll go through an example .NET 5.0 API that supports user registration, login with JWT authentication and user CRUD operations. The API is configured to use a local SQLite database in development and a SQL Server database in production. It uses Entity Framework Core migrations to automatically generate the database on startup, for more info on EF Core migrations see...
自 .NET 发布起，.NET Framework 运行环境就是其摆脱不掉的桎梏。后来有了 .NET Core ，微软终于将自带运行时和单文件程序带给了我们。即便如此，大部分情况下开发者仍然不太满意：一个简简单单的控制台应用程序，甚至只包含一个 Hello World ，附带运行时的单文件程序打包出来就需要 20M+ 。.NET 程序的发布受一个名为 发布配置文件 (.pubxml) 的 XML 文件控制，该文件默认不存在，会在第一次在 Visual Studio 中执行发布时创建。该文件会被保存在项目的 Properties/PublishProfiles 目录下，可以在以下微软文档上看到更详细的介绍...
Zip files are the most ubiquitous compression format in computing history, with it first being invented in 1986 by Phillip Katz. Since then, the Zip file has found its way into every operating system as the de facto compression method. It’s only right that .NET developers become familiar with the format and have the necessary tools to work with these files programmatically. In this post, we’ll look at the ZipFile utility class, how to compress files and directories, along with decompressing zip files.
I am building an app with .NET 5 and ASP.NET Core 5. And, I want to run it on a cloud provider. Since .NET 5 isn't widely adopted yet (and probably won't be since it's not an LTS version), that means the easiest path to deployment is a Docker image. That part isn't hard. When you create a new .NET project, you get a multi-stage Dockerfile for free (well, as long as you select that option). But, I want to use vanilla Node.js build options for processing and bundling my CSS and JS files. The common solutions I've seen for Docker + Node + .NET involve starting with the base .NET image and then using apt-get to install Node. I didn't want to go down that path if I could help it. I don't know why, but the idea of modifying the Docker image outside of just building stuff offended my aesthetic.
The .NET team publish Docker images for every release of the .NET SDK and runtime. Running .NET in containers is a great way to experiment with a new release or try out an upgrade of an existing project, without deploying any new runtimes onto your machine.
In this article, we will learn about RESTful WebAPI with .NET 5 (Successor of .NET Core 3.1).We will create a new WebAPI project with .NET CLI in VS CodeWe will see what’s new provided with .NET 5 WebAPI template...
在最近在做 WPF 框架开发的时候，看到了在 WPF 的 StaticExtension 里面，有部分逻辑采用了反射的方法去获取静态字段和静态属性。此时我第一个反应就是这部分逻辑的性能有锅，于是尝试了进行加上缓存来优化。但是在使用了 Benchmark 进行性能测试的时候发现了，其实加上了缓存的性能反而更差，也就是说在 dotnet 5 里面的反射获取静态字段和属性的性能没有想象的伤性能。本文并非说反射获取静态字段和属性不伤性能，而是指在本文约定的情况下，没有那么伤性能。本文完全依靠性能测试来说明。