Posts
Create a CRUD Web API in minutes with Data API Builder and EF Core Power Tools
Data API Builder is a .NET container based app, that based on a json configuration file can expose a CRUD Web API supporting both REST and GraphQL endpoints.
What is new in Entity Framework 6.5 Classic
More than 4 years after the last release of Entity Framework (version 6.4), a new version 6.5 is currently in preview, planned for release in May/June 2024.
Create a Custom Static Code Analysis Rule for Azure SQL Database / SQL Server with .NET
This walkthrough demonstrates the steps used to create a SQL Server Code Analysis rule. The rule created in this walkthrough is used to avoid WAITFOR DELAY statements in stored procedures, triggers, and functions.
How to: Code analyze your SQL Server T-SQL scripts in Visual Studio
Maybe you already take advantage of the C# code analyzers built into the .NET SDK, that help you improve code consistency, quality, security and avoid common mistakes and potential bugs.
Better together with Entity Framework Core Power Tools - use a SQL Server Database Project (.dacpac) and EF Core
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? This is possible With help from EF Core Power Tools!
Use SQL Server Compact with .NET 7/8 and Entity Framework (Classic) with Database First work flow
In this blog post I will show how you can use SQL Server Compact 4.0 on a Windows desktop with .NET 7 (and later), with a Database First approach, assuming you already have a SQl Server Compact .sdf database file available.
Use DateOnly and TimeOnly with EF Core 6, 7 & 8 and Azure SQL / SQL Server
SQL Server added the
date
(andtime
) data types in 2008 - now, 15 years later, you can finally take full advantage of these data types with Entity Framework Core and save at least 50% disk space and bandwidth withdate
.From Azure SQL DB to EF Core Web API using only cross platform CLI tools
Cross platform support with .NET and Azure SQL Database tools has improved tremendously in the recent years. To prove this, I wanted to test if you can expose an Azure SQL Database table from a ASP.NET Core Web API using just command line tooling. And as you can see during the process, there is still room for improvements!
Using .NET 6 DateOnly (and TimeOnly) with SQL Server
The DateOnly and TimeOnly types are new additions to .NET that were added in .NET 6 in 2021.
Use dependency injection and .NET logging with Microsoft.Data.SqlClient
Microsoft.Data.SqlClient
is the open source .NET data provider for Microsoft SQL Server. It allows you to connect and interact with SQL Server and Azure SQL Database using .NET.Entity Framework Core Power Tools- a visual guide to recent updates
EF Core Power Tools can now celebrate close to 250.000 installs!
Tales from the trenches - moving an old and large offline database to Azure SQL Database with SqlPackage
sqlpackage
is a Microsoft provided command-line utility that automates a number of database development tasks by exposing some of the public .NET based Data-Tier Application Framework (DacFx) APIs.Make your SQL Server Database project (.sqlproj) build with .NET Core - even on Linux or macOS!
A couple of years ago I blogged about a great community project that enables you to build a .dacpac using dotnet build, even on Linux and Mac.
Add an admin CRUD web page to your ASP.NET Core web app in 5 minutes using EF Core Power Tools and CoreAdmin
Sometimes, maybe in the early stages of the development of a new product/solution, you may find yourself needing a simple way of letting customers edit some parts of the data in a solution.
Avoiding SQL Server plan cache pollution due to unparameterized Contains queries generated by Entity Framework 6
In this post I will describe an approach to solving an issue with Entity Framework 6 and queries using
Contains
I have previously blogged about.Avoiding SQL Server plan cache pollution due to unparameterized Contains queries generated by EF Core
In this post I will describe an approach to solving an issue with EF Core and queries using
Contains
I have previously blogged about:Using Microsoft.Data.SqlClient with Entity Framework 6
Want to use Microsoft.Data.SqlClient with Entity Framework 6 - this is now possible! This blog post describes the why and how.
Look ma, no passwords - using Entity Framework Core with Azure Managed Identity, App Service/Functions and Azure SQL DB
Storing passwords anywhere is never recommended practice, and that is why so called "Integrated Authentication" is always recommended when connection from a Web App running IIS against SQL Server.
Advanced automated deployment of Azure SQL Database with Azure DevOps (part 4 of 4)
In this blog post series, I will show how to implement various advanced requirements when deploying an Azure SQL Database using Azure DevOps yaml-based pipelines, and ARM templates. I assume you have some experience with these technologies in advance.
Advanced automated deployment of Azure SQL Database with Azure DevOps (part 3 of 4)
In this blog post series, I will show how to implement various advanced requirements when deploying an Azure SQL Database using Azure DevOps yaml-based pipelines, and ARM templates. I assume you have some experience with these technologies in advance.
Advanced automated deployment of Azure SQL Database with Azure DevOps (part 2 of 4)
In this blog post series, I will show how to implement various advanced requirements when deploying an Azure SQL Database using Azure DevOps yaml-based pipelines, and ARM templates. I assume you have some experience with these technologies in advance.
Advanced automated deployment of Azure SQL Database with Azure DevOps (part 1 of 4)
In this blog post series, I will show how to implement various advanced requirements when deploying an Azure SQL Database using Azure DevOps .yml-based pipelines, and ARM templates. I assume you have some experience with these technologies in advance.
Entity Framework Core 5 free resources
It is now almost two months since EF Core 5 was launched at the .NET Conf 2020 online event on November 10, 2020.
Get a SQL Server stored procedure return value with EF Core
SQL Server stored procedures can return data in three different ways: Via result sets, OUTPUT parameters and RETURN values - see the docs here.
Setting the command timeout with the latest .NET SqlClient
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.
Entity Framework Core SQL Server reverse engineering a.k.a Database First gotchas (and workarounds)
This post lists some of known issues you may encounter with Entity Framework Core Power Tools SQL Server reverse engineering or when running the
dotnet ef dbcontext scaffold
command, and provides resolutions / workarounds for the issue.Tips for making the most of EF Core with Azure SQL Database
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.
EF Core Power Tools database reverse engineering: renaming of entities and properties
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.
Creating, building and publishing Azure SQL Database projects on non-Windows platforms
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.
EF Core Power Tools reverse engineering advanced options
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.
Using SQL Server Compact 4 with .NET Core 3.1 (on Windows only)
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.
Mapping and using SQL Server stored procedures with EF Core Power Tools
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.
Run migration scripts with sqlcmd and avoid issues with QUOTED_IDENTIFIER
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!
How to call stored procedures with OUTPUT parameters with FromSqlRaw in EF Core
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.
Breaking changes in Microsoft.Data.SqlClient 2.0 (and potential mitigations)
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.
Walk-through: Using an Entity Framework 6 EDMX file with .NET Core
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.
Tips for .dacpac (SQL Server database project) deployment
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.
Get a single, simple type value from a stored procedure with Entity Framework Core and raw SQL
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.
Simple logging with Entity Framework Core 5 and 'LogTo' (like Database.Log in EntityFramework 6)
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 -
dotnet build
.New features in Microsoft.Data.SqlClient 2.0 preview 3
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.
Pluralization with EF Core and EF Core Power Tools
EF Core 3 supports pluralization by convention, and allows you to enable and customize it. This blog post will show you how!
How to pass a dynamic/variable list of values as SqlParameters with FromSqlRaw in EF Core
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!
Generate Entity Framework Core classes from a SQL Server database project - .dacpac file
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!
Query non-table classes using ad-hoc (raw) SQL with EF Core 3.1
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.
Avoiding SQL Server plan cache pollution with EF Core 3 and Enumerable.Contains()
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