Entity Framework Core supports constructors with arguments

Keeping objects complete and valid all the time is strategy used in different methodics. It’s perhaps most popular in Domain Driven Design (DDD). Entity Framework Core 2.1 made big step forward on supporting entities that doesn’t have default empty constructor. This blog post shows how to use Entity Framework Core and entities with constructor arguments.

Read more

New killer features planned for .NET Core, ASP.NET Core and Entity Framework Core 2.1

Microsoft announced roadmap for upcoming release of .NET Core family versioned as .NET Core 2.1. While there are some new features and many improvements coming I compiled a list of my favorites that I see as most imortant to all developers building solutions on .NET Core, ASP.NET Core and Entity Framework Core.

Read more

Entity Framework Core with .NET Core console application

ASP.NET Core makes it very easy to configure and use Entity Framework Core in web applications. For .NET Core console applications there is no such machinery available but we can still use Entity Framework Core in console applications. This post shows how to wrap database context initialization to separate class and use Entity Framework Core synchronous and asynchronous calls in .NET Core console application.

Read more

Performance of compiled queries in Entity Framework Core 2.0

Before applying any optimizations to our code we have to ask one question: what is the cost of improvement and is it really improvement? Compiled queries in Entity Framework 2.0 are categorized as high-availability feature but before making any decisions we need to know what is the actual win. This blog post introduces the measurements I made with simple database context to compare compiled and uncompiled queries in Entity Framework Core 2.0.

Read more

Writing IL code on Visual Studio

Microsoft Intermedia Language (MSIL) is .NET assembly language that is standardized under name Common Intermediate Language (CIL). All .NET compilers turn source code to this language. Although we hardly have a situation where we have to write intermedia language (IL) code directly it is still good to know how it works and how it is supported on Visual Studio. This blog post fills the gap and shows how to write IL code on Visual Studio.

Read more

How to avoid overlapping timer calls?

Timers are useful .NET feature. With timers we can execute code with specified interval. With real scenarios we can easily face situations where timer calls its callback again but previous call is not finished yet. It may end up with loading some external system too much. It may also end up by making unexpected parallel data processing that distorts the results. This post introduces some options to avoid overlapping timer calls.

Read more

Are lock and Monitor the same in C#?

Working on some threading stuff I stumbled upon some discussions about lock and Monitor. Some say they are different and some say they are the same. I took few minutes of time to make some simple experiments with both of these. This blog post shows what C# compiler does with lock statement. As I had to use also Monitor class I added one example here how to use it instead of lock.

Read more