Run maintenance jobs on Azure SQL

Azure SQL, do not forget to schedule maintenance

Many users on Azure SQL Server do not realize they have to do their own maintenance on Indexes. This index will slowly become fragmented and the performance will decrease over time. Azure SQL does not have a Job scheduler (agent) like on premise. In this post I’ll describe how to schedule a maintenance job from an ASP.NET Core application.
Continue reading “Run maintenance jobs on Azure SQL”

Advertisement

Upgrade ASP.NET Core and Entity Framework Core 2.0 to 2.1

In the past weeks we have upgraded our ASP.NET Core 2.0 project to 2.1. The main reason for the upgrade is using the latest signalr capabilities and hosted services. The issues we had are related to the features we use. In our case the upgrade encountered some minor issues. In this blog post I’ll show what we had to change and give some tips on how to upgrade.

Continue reading “Upgrade ASP.NET Core and Entity Framework Core 2.0 to 2.1”

Cannot access a disposed object in ASP.NET Core when injecting DbContext

Find the root cause of what really happened to you disposable object.

Working with ASP.NET core I have seen this error multiple times and can be hard to debug. The error can have multiple root causes. It can be a real pain to find the cause and it is sometimes fixed by only taking care of the symptoms. By finding the root cause, you can take the appropriate action in your code.

Continue reading “Cannot access a disposed object in ASP.NET Core when injecting DbContext”

Increase timeout Migrations Entity Framework Core

Use a different connection timeout when running your migrations with EF Core.

Sometimes a migration takes more time then your default timeout of your database connection. In such a case you do want to increase the timeout for the migration to be able to complete, but you do not want to change the timeout for your normal operations.
Continue reading “Increase timeout Migrations Entity Framework Core”

Add Index with Include Entity Framework Core

This post explaines how to add index to EF Core with extra columns included from code.

When creating indexes with code first migrations in Entity Framework Core you can create an index on a table by adding the following to your DbContext:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    modelBuilder.Entity<table>() 
        .HasIndex(t =&gt; new { t.Column1, t.Column2}); } 

Continue reading “Add Index with Include Entity Framework Core”

Implement Pessimistic Concurrency in Entity Framework Core

ConcurrencyIn a scenario where we were using SQL server as a queue, before publishing events to external queues, we wanted the data to be processed only once and in order, even with multiple processors for failover. When reading from the table we wanted to lock the records and block other processors from reading those records, while being processed. This is called Pessimistic Concurrency, unfortunately Entity Framework Core does not support this out of the box. To realize Pessimistic Concurrency you need to write your own SQL queries directly on the database (The solution is database type bound, in this case Microsoft SQL server). This blog post will show how it can be accomplished.
Continue reading “Implement Pessimistic Concurrency in Entity Framework Core”

Entity Framework and Full Text Search

Out of the box Entity Framework does not support Full Text Search. To do Full Text Search you have a number of options to get it working. In this blog post I’ll describe a method to get Full Text Search working using a table valued function. The method does the Full Text Search in a table valued function that returns an id list, the returned ids can be used to filter the records from an actual table.
Continue reading “Entity Framework and Full Text Search”