Latest Articles

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 →

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 →

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 →

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 →

Configure One to One Relationship in Entity Framework Core

Entity Framework Core will create a one-to-one relationship when both entities involved in the relationship have a navigational property of the other and the dependant entity contains a foreign key property of the principal entity.

Read More →

The entity type 'X' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'

I got the following error when I ran the add-migration command for the following entity. The entity type 'Student' requires a primary key to be defined. If you intended to use a keyless entity type,call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943.

Tags:  Troubleshooting

Read More →

Sample Code to Create, Read, Update and Delete (CRUD) records, EF Core Many to Many relationship

This article explains how CRUD(Create, read, update, delete) operations can be performed using Entity Framework Core on tables connected through a many-to-many relationship. An asp.net core razor page application is used to demonstrate this.

Read More →

Configure Many-to-Many Relationships in Entity Framework Core Code First

In RDBMS, we call a relationship between two tables many to many when more than one record in one table is associated with multiple records in the other table. In EF Core 5.0, a many to many relationship can be created without defining a joining table.

Read More →

Fix: The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program.

add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included,verify that the path is correct and try again.

Tags:  Troubleshooting

Read More →

The seed entity for entity type 'X' cannot be added because a non-zero value is required for property 'Id'

In Entity Framework Core, primary key properties are converted to identity columns if the database provider is SQL Server. But when we try to seed a database table with an identity column, the corresponding property value should be provided, as the migration scripts are generated by Entity Framework without connecting to the database.

Tags:  Troubleshooting

Read More →

Data Annotations in EF Core

.NET provides a set of data annotation attributes that can be used to define constraints to the tables and the columns in the underlying database and override  Entity Framework Core conventions.

Read More →

HTTP Error 500.34 - ASP.NET Core does not support mixing hosting models

"HTTP Error 500.34 - ASP.NET Core does not support mixing hosting models". You will get this error if you host two .NET Core web applications in the same application pool using In-process hosting. This error can be fixed using two methods. One solution is using different application pools for the web applications.  The other solution is changing the hosting model of the applications to "OutOfProcess". 

Tags:  Troubleshooting

Read More →

Conventions in Entity Framework Core

Conventions are the default rules that control how a model will be mapped to a database schema. Entity Framework core follows these default rules when it is not overridden using Data Annotation Attributes and Fluent API.

Read More →

Search