Showing all posts tagged: 'ef core'

A 5-post collection

EF Core, String Interpolation and SQL Injection

EF Core has always provided support for inline SQL queries. This means that you could pass a T-SQL query to be executed through the current DbContext. A typical example would look like this: var term = "some search term"); var blogs = db.Blogs.FromSql($"SELECT * FROM dbo.Blogs WHERE Title = {term}") .OrderBy(b => b.Url) .Select(b => b.Url); This feature is great if you need to call a table function etc. I would urge that this feature is used in moderation and with careful consideration. Calling raw T-SQL requires that developers understand the potential …[read more]


Improving EF Core performance with Compiled Queries

EF Core 2.0 is production ready and it's now fully RTM. Therefore, I hope that by now you have had the chance to take it for a spin and use it in your code. There are many compelling reasons why you would want to use EF Core such as performance, portability and size being. The latest release of 2.0 has added a number of new features making it a very compelling ORM. Friendly reminder: EF Core can run both on the full .NET Framework and .NET Core. Don't let the "core" in the name confuse you. …[read more]


Scaffolding DbContext and Models with EntityFramework Core 2.0 and the CLI

EF Core 2.0 has been out for a few weeks now. If you're looking at an ORM for your .NET application then EF Core should be at the top of the list of possible options. I say at the top and not the only one because depending on the project requirements, some features may be missing. For example, EF Core cut ties with .edmx so if you want to stick with the designer feature you will need to use EF6. There are other limitations so make sure you have a look at [this post](https://docs.microsoft.com/en-us/ …[read more]


Query Profiling on Azure SQL

[Azure SQL](https://azure.microsoft.com/en-us/services/sql-database/?v=16.50" target="_blank) is one of the most valuable Platform as a Service (PaaS) offerings on Azure, second only to Web Apps. It's incredibly cost effective and fully featured. It supports a number of database versions and can be deployed in seconds. The other day I was looking to test something with EF Core and I needed a database to run queries against. I went to the Azure portal, I created a database with prepopulated data using the AdventureWorks (Datawarehouse Workload - DW) and I was ready …[read more]


EF Core migrations with existing database schema and data

I'm currently working on an inherited .NET Core project and I'm loving the experience. I'm still using the project.json project format instead of the newer *.csproj & msbuild one. For now I'll leave it as it is but going forward I'll use the new format for subsequent ASP.NET Core projects. The project also makes use of the newest [EF Core](https://docs.microsoft.com/en-gb/ef/" target="_blank) so it's all running on the edge of the .NET technology. EF Core Code First is great but the tooling is still rough around the edges. Some things …[read more]