SQL Server stored procedures can return data in three different ways: Via result sets, OUTPUT parameters and RETURN values - see the docs here.
With the latest 2.1.0 preview 2 release of the open source .NET client driver for Microsoft SQL Server and Azure SQL Database, Microsoft.Data.SqlClient, it is now possible to set the default command timeout via the connection string.
This post lists a number of known issues you may encounter with Entity Framework Core Power Tools SQL Server reverse engineering or when running the
dotnet ef dbcontext scaffoldcommand, and provides resolutions / workarounds for the issue.
Azure SQL Database is Microsoft a managed cloud database, that is highly compatible with SQL Server. The Azure managed database service takes care of scalability, backup, and high availability of the database. Azure SQL Database includes built-in intelligence that learns app patterns and adapts to maximize performance, reliability, and data protection.
Entity Framework Core Power Tools (my free, open source Visual Studio extension, that helps you be more productive with EF Core), includes a feature to rename entities and properties.
For a while now, it has been possible to publish a .dacpac file (meaning apply it to an new or existing database) using the cross-platform version of sqlpackage.
The main feature of Entity Framework Core Power Tools is the ability to reverse engineer a live database or a SQL Server Database project, and generate customized code with a derived DbContext and entity classes.
Despite the age and soon complete end of support in July 2021 of SQL Server Compact 4 (launched in 2010), some (actually few) wonder if it is possible to use it with .NET Core. I will show how this can be done here.
In my previous post I showed how you can map and use stored procedures manually from EF Core, a process which involved quite a bit of code, and some changes to your derived DbContext.
Maybe you did not know this, but the recommended way to deploy Entity Framework Core migrations to a production database is by generating SQL scripts!
In this post I will show how you can call stored procedures with OUTPUT parameters from EF Core. I am using the Northwind database for the sample code.
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