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.
在官网下载Es，注意版本号，不同大版本号之间差异很大。我安装的是7.14.0版本1.1 安装成服务cmd 进入bin目录下执行elasticsearch-service.bat install1.2 安装插件ik分词器，分词器的版本和ES版本需要一致elasticsearch-plugin.bat install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.14.0/elasticsearch-analysis-ik-7.14.0.zip1.3 配置账号密码修改config目录下面的...
Analyzers have been built into the C# compiler for some time now. Anyone can write their own analyzer, distribute it as a NuGet package, and hook into the compiler to find potential code issues. In this post I look at the changes to the existing ASP.NET Core analyzers in .NET 6, as well as the new ones added for the new minimal APIs. This post ended up a little long, so I've included shortcuts to each of the analyzers I describe in case you want to skip ahead...
C# Records have been out for a while now and I purposely avoided jumping on the band wagon as all the other bloggers out there in proclaiming how amazing they are. In my opinion, C# Records have been out just long enough for developers to start using them and unfortunately also misusing them. I am encountering a number of situations where Records are being used and it makes no sense why and none of the functionality they provide is being used.
In this article, we’re going to explore the Google Sheets API using the Google Sheets Client Library for .NET. We’ll start with configuring the Google Sheets API in the Google developer console. Then we’ll build an ASP.NET Core application that can read and write data into a google sheet. To downloa...
Great tweet from Oleg Kyrylchuk (follow him!) showing how cool Parallel.ForEachAsync is in .NET 6. It's new! Let's look at this clean bit of code in .NET 6 that calls the public GitHub API and retrieves n number of names and bios, given a list of GitHub users
.NET 6 Release Candidate 2 (RC2) is now available. .NET 6 RC2 is very close to the final build of .NET 6 that we expect to ship in November this year in time for .NET Conf 2021. It’s also a “go live” release, so you’re welcome to use it in production. .NET 6 RC2 primarily contains quality improvements and bug fixes, although it does also include a few new features as well.
In this blog post, let’s look at another interesting feature of C# 10.0 which is called extended property patterns. I’ve written a bigger blog post about pattern matching in C# 9.0. If you’re not familiar with pattern matching, I recommend you to read that blog post.
Welcome back to my series on new C# 10 features. I kicked off this series by writing about file-scoped namespaces, a simple but powerful way to remove unnecessary verbosity from your C# code. This time, we're talking about a new feature that achieves similar goals: global using declarations.
Recently I had some issues with running a local IIS server/website on my local development machine. The solution was fairly well documented, but the surprising culprit and the fact that it had never happened to me before (despite it being a replicable process) made it worthwhile documenting.
Back in 2019, when the .dev top-level domain opened, we picked up vscode.dev and quickly parked it, pointing at our website code.visualstudio.com (or, if you are from the Boston area like me, we "pahked it"). Like a lot of people who buy a .dev domain, we had no idea what we were going to do with it. And we certainly didn't anticipate that it would end up being the fulfillment of a mission over a decade in the making.
GraphQL is a platform-independent, language-neutral query language and may be used to run queries and retrieve data. Joydip Kanjilal explains how to use GaphQI in an ASP.NET Core 5 app.
I’ve grown fond of SQLite during my time as a developer advocate. The file-based database with native drivers for every operating system allows me to ship self-contained data-driven sample apps to developers worldwide. Developers can clone a demo and run it immediately without the need for additional dependencies like a database server, Docker container, or remote hosting environment. It’s excellent, and I’m sure my readers appreciate it.
In the previous post I described the workaround that was added in .NET 6 so that the EF Core tools, which previously relied on the existence of specific methods like CreateHostBuilder would continue to work with the new minimal hosting APIs. In this post I look at a related change to ensure that integration testing with WebApplicationFactory works in .NET 6. WebApplicationFactory used the same HostFactoryResolver class as the EF Core tools, but it required a few more changes too, which I'll look at in this post.
The support for Async Streams was one of the most exciting features that came out with .NET Core 3.0 and C# 8. This is possible with the use of IAsyncEnumerable with the yield operator. In this article, we are going to explore how to take advantage of this new feature to improve our code.
A nice new overload is coming to LINQ's OrDefault methods (e.g. FirstOrDefault()), so let's check it out! In prior versions of .NET, we could use methods such as FirstOrDefault() to specify that we wanted the first element in a collection, or the default value of the element's...
On behalf of our entire team, I’m excited to announce the upcoming release of Visual Studio 2022 on November 8, and the immediate availability of the Visual Studio 2022 Release Candidate (RC) and Preview 5. We invite you to explore the latest capabilities of Visual Studio 2022 at our virtual launch event on November 8. Throughout the day, you can learn from some special guest speakers, talk back to the Visual Studio team, and even download exclusive digital swag.