Athough EF Core is a developer friendly Object-Relational Mapper (ORM), working with it isn't without its challenges. One error that we encountered during a pair programming session was: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value In this blog post, we will delve into the causes of this error and explore ways to resolve it. "Constructing a database in the 18th century" - Generated by AI Understanding the error This error typically occurs when there is an attempt to convert a datetime2 value in SQL Server to a datetime value, and the value falls outside the valid range for the datetime data type. datetime : This data type in SQL Server has a range from January 1, 1753, to December 31, 9999, with an accuracy of 3.33 milliseconds. datetime2 : This newer data type, introduced in SQL Server 2008, has a much broader range from January 1, 0001, to December 31, 9999, with an accuracy of 100 nanoseconds.
When working with MassTransit, registering consumers can become cumbersome if you have many of them. Luckily, MassTransit provides a way to register all your consumers automatically using AddConsumers . This post will guide you through the process of setting up and using AddConsumers to simplify your consumer registration. What is MassTransit? MassTransit is an open-source distributed application framework for .NET, which simplifies the creation and management of message-based systems. It supports various messaging platforms like RabbitMQ, Azure Service Bus, and Amazon SQS. Setting Up MassTransit Before diving into consumer registration, let’s quickly set up a MassTransit project. Step 1: Install MassTransit Packages First, install the necessary MassTransit packages via NuGet. You can use the following command on your favorite command line: dotnet add package MassTransit.RabbitMQ Step 2: Configure MassTransit In your Program.cs or wherever you configure your service