Microsoft.Data.SqlClient version 2 has just been released. This library is the latest and greatest .NET client driver for SQL Server and Azure SQL Database - and will be used by EF Core 5. In addition to a number of new features (which I blogged about earlier), this major version release also includes a number of breaking changes.
With the 6.4 release of Entity Framework, it is possible to use Entity Framework 6.x from a .NET Core app. This can be useful for quick porting of existing applications (for example desktop apps, console apps or even Windows services or ) if you would like to take advantage of .NET Core with those.
I have previously blogged about using a SQL Server Database Project together with EF Core and also described a NuGet package that enables you to build a .dacpac with .NET Core, even on Linux and macOS.
With a little sleight of hand and some LINQ magic, it is possible to query scalar values using just Entity Framework Core and FromSql, without having to resort to raw ADO.NET and ExecuteScalar.
Logging with .NET Core (and Entity Framework Core) requires some plumbing, and requires you to opt-in to the built-in Dependency Injection infrastructure, which you have to enable manually for application types that are not ASP.NET Core. As you can see from the docs, it can quickly get quite complicated.
Build (and publish) a .dacpac (SQL Server database project) with .NET Core - even on Linux or macOS!
In this post, I will describe how you can build a SQL Server Database project in order to create a .dacpac file, using .NET Core only -
Microsoft.Data.SqlClient is the .NET data provider for Microsoft SQL Server and Azure SQL Database. It is a union of the two legacy System.Data.SqlClient components which live independently in .NET Framework and .NET Core. Going forward, support for new SQL Server features will only be implemented in Microsoft.Data.SqlClient.
EF Core 3 supports pluralization by convention, and allows you to enable and customize it. This blog post will show you how!
As a sort of follow up to my blog posts here and here I will show how to use a dynamic list of values a parameters when using FromSqlRaw. The condition in this case that you may sometimes be calling your method with 5 parameters, sometimes with 20 etc. Keep in mind that the maximum number of parameters with SQL Server is 2098!
Imagine combining the power of the design time tools and syntax verification you get from a SQL Server Database Project (.sqlproj) with the power of well-formed and properly parameterized SQL, change tracking capabilities and more, that you get from Entity Framework Core? With help from EF Core Power Tools (or a Nuget package), that is now possible!
Many Entity Framework Core users look for an implementation of something similar to SqlQuery from Entity Framework 6 or even something like Dapper's strongly typed Query extension method. SqlQuery/Query translates a raw SQL query to a IEnumerable of the type referred. In this blog post, I will show, that with a single line of extra code, it is possible to achieve the same for complex types with EF Core 3.1.
One of the many advantages of using a tool like Entity Framework Core is, that you are sure that the framework will generate properly parameterized SQL for you. This helps avoid SQL injection issues and avoids plan cache pollution. Unfortunately, EF Core currently falls short on that promise, when translating queries, where you supply a list of values to be matched against a column - Enumerable.Contains method - this is translated to a SQL Server IN operator
Update your Microsoft.Data.SqlClient dependency if you run EF Core 3.1 with Linux/Docker, to avoid deadlock (hang) issues
If you use Entity Framework Core 3.1.x with SQL Server from a Linux machine, consider updating to use a more recent version of Microsoft.Data.SqlClient.
subscribe via RSS