Latest Articles

Implementation of Custom Server-Side Validation Rules in ASP.NET

We use validation attributes in ASP.NET Core to validate model properties. These validation attributes are available in System.ComponentModel.DataAnnotations namespace. Even if there are many built-in validation attributes, we will sometimes have to use custom validation attributes to enforce our business rules. This article explains how it can be done.

Read More →

How to run SQL scripts in a file using EF Core migrations?

The Entity Framework code-first approach gives powerful tools to create and manage database objects like tables, fields and their constraints, etc. This article will help you if your application uses stored procedures, functions, and similar database objects and you want to create these objects in the database as part of the migrations.

Read More →

Cannot convert from 'long?' to 'long'

I use a code similar to the following to accept the value for a query string named Id on one of my pages of a .NET Razor Page application. It is an optional query string. Its value is then passed to another function for further processing. When I compile the code, I get the error message "cannot convert from 'long?' to 'long'"

Tags:  Troubleshooting

Read More →

Your target project [ProjectName] doesn't match your migrations assembly [AssemblyName]. Either change your target project or change your migrations assembly.

I am working on a project in ASP.NET Core 5.0, which contains a web application and the related class libraries. I use Entity Framework Core for data access. My DbContext is in a class library project. When I run the add-migration command I get this error.

Tags:  Troubleshooting

Read More →

How to change the port of a Next.Js application

When you run a Next.Js application locally in development mode, it uses the port number 3000. When you run more than one Next.Js application locally, you will get a message saying, "Port 3000 is already in use."  and you won't be able to start the second application using the same port. There are different methods to change the default port number.

Read More →

Module not found: Can't resolve 'react-router-dom'

I got this error "Module not found: Can't resolve 'react-router-dom'" when I tried to import and use the 'react-router-dom' package in my React application. This package allows us to add routing functionality to React.

Tags:  Troubleshooting

Read More →

Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

When I run my React JS application, I get the following error. Error: App(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

Tags:  Troubleshooting

Read More →

Configure Billing Alarm in AWS

AWS CloudWatch is a monitoring and management service in AWS that provides data and actionable insights for AWS resources. You can use CloudWatch to monitor your billing data and send alerts when the bill amount exceeds a certain threshold.

Read More →

Load Relational Data Using Include and ThenInclude in Entity Framework Core

Entity Framework Core allows you to load related entities using the navigation properties in your model. Related entities can be loaded using different ways. If you use eager loading, it will enable you to access relational data in a single database call. In eager loading, related data can be loaded using Include and ThenInclude methods.

Read More →

Installation of DynamoDB locally on Your Windows Machine

Amazon DynamoDB is available for download as a.jar file that runs on Windows, Linux Mac OS, and other platforms that support Java. Before downloading and running DynamoDB locally, you need to install Java Runtime Environment if you don’t have it on your system.

Tags:  DynamoDB

Read More →

Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate... error

When I tried to register a service that uses an object of System.Net.Http.HttpClient  for dependency injection, I got this error "Unable to resolve service for type 'System.Net.Http.HttpClient' while attempting to activate "

Tags:  Troubleshooting

Read More →

Querying in Entity Framework Core (EF Core) - Sorting, Filtering and Grouping

 Entity Framework Core uses Language-Integrated Query (LINQ) to query the database. You can use C# or any .NET language of your choice to write LINQ queries. The queries you write in LINQ are passed to the database provider. The database provider translates it to the actual SQL, which will be executed against the database.

Read More →

Server Side Pagination Using Stored Procedure and Dapper in ASP.NET Core Razor Pages

This article explains how paging can be implemented using the stored procedure in ASP.NET Core Razor Pages. When you have millions of records in the database and need high performance and complete control over the query to be used for pagination, you can use stored procedures.

Tags:  Razor Page PaginationPagination

Read More →

The 'async' modifier can only be used in methods that have a body.

I declared a method in my interface using the async modifier and I am getting the error "The 'async' modifier can only be used in methods that have a body"

Tags:  Troubleshooting

Read More →

Solution For Blazor Error - Cannot provide a value for property, There is no registered service of type [TypeName]

While experimenting with Blazor, I ran into "There is no registered service of type [TypeName]" error. I was trying to use a new service on a Blazor component by injecting the service into it.

Tags:  Troubleshooting

Read More →

Code Snippet to Create a Checkbox List in an ASP.NET Core Razor Page Application

Checkbox lists are useful when you want to allow users to select more than one predefined option. This article explains how a Checkbox list can be generated, and the selected checkbox values can be retrieved when the page is submitted in an ASP.NET Core Razor Page application.

Read More →

HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure

I got the following error when I deployed my ASP.NET Core Razor page application to the production server after updating some NuGet packages to the latest version. HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure

Tags:  Troubleshooting

Read More →

Unable to create an object of type '[DBContextName]'. For the different patterns supported at design time see https://go.microsoft.com/fwlink/?linkid=851728

You may get the following error when you run the add-migration command in EF Core 5.  Unable to create an object of type '[DBContextName]'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

Tags:  Troubleshooting

Read More →

EF Core Migration Error: The query contains a projection '<>h_ Transparent Identifier 0 Collections in the final projection must be an 'IEnumerable<T>' type such as 'List<T>'.

The query contains a projection '<>h__TransparentIdentifier0 Collections in the final projection must be an 'IEnumerable' type such as 'List'. Consider using 'ToList' or some other mechanism to convert the 'IQueryable' or 'IOrderedEnumerable' into an 'IEnumerable'.

Tags:  Troubleshooting

Read More →

Configure One to Many Relationship in Entity Framework Core

A one-to-many relationship is the most commonly used relationship while developing database-oriented applications. Entity Framework Core identifies one-to-many relationships based on the conventions. Fluent API can also be used to configure the relationship if the entities do not follow the conventions.

Read More →

Search