Effortless Logging In .Net Core and Asp.Net Core version > 2

logging in asp.net core

Logging In Asp.Net Core .Net core support a variety of built-in and third-party providers. The Logging API is included in the Microsoft.Extensions.Logging package. The Logging API does not work as a standalone. It works with one or more logging providers that store or display logs to a particular medium such as Console, Debug, Trace Listeners, etc. So, there are two important building blocks for implementing logging in a .NET Core based application: Logging API Logging Providers Microsoft.Extensions.Logging includes the necessary classes and interfaces for logging. The most important is the ILogger, ILoggerFactory, ILoggerProvider…

Read More

How to handle errors in asp.net core globally or Centralize

Asp.net-core By Sagar Jaybhay

Centralize way to handle errors in asp.net core by sagar jaybhay In Case You do not handle the error at a respective method-level then our global exception handler comes in picture and display appropriate message. Below are the steps to add a global filter in your asp.net core application to handle errors in asp.net core globally or Centralize way Step 1: Add below the line of code in your configure method in startup class. Now your code likes below. In process of Centralize way to handle errors, we pass Error…

Read More

How to handle 404 Not Found Error in Asp.Net core?

Asp.net-core By Sagar Jaybhay

Different Ways to handle status code errors in asp.net core by sagar jaybhay If resources are not found for specific value or id. In this, we need to redirect user to custom error page where he can find the error message that for corresponding value he didn’t found any information in our scenario student not found for the corresponding student id. Means in this we need to display an error message in a way that end user will understand that whatever he looking for is not found on the server.…

Read More

Entity Framework Code First Migration In Asp.net Core

Code First Entity Framework Migration In Asp.Net Core By Sagar Jaybhay Migration helps to sync database schema with the model classes. In entity framework code first we have different database initialization strategies like . CreateDatabaseIfNotExists, DropCreateDatabaseIfModelChanges, and DropCreateDatabaseAlways.and there is one problem with these strategies like if you have existing stored procedure,triggers or you have any other database objects. When you use the above-mentioned strategies they will re-create the database so you may lose your data and other db objects. So entity framework core introduces a migration tool that automatically…

Read More

Repository Pattern In Asp.Net Core MVC

Repository Pattern in asp.net core mvc

Repository Pattern In MVC by Sagar Jaybhay The Repository Pattern is one of the most popular patterns to create an enterprise level application. It restricts us to work directly with the data in the application and creates new layers for database operations, business logic, and the application’s UI. Repository pattern is abstraction of the data-access layer and it hides the details about how the data is stored, retrieve from the underlying database. In the real-life project, it is not good idea to access database logic directly in the business logic. When you write…

Read More

How to Install Entity Framework and Configure in Asp.Net

Asp.net-core By Sagar Jaybhay

First part of Entity Framework Link In this article i will explain How to Install Entity Framework and Configure for sql server in asp.net core mvc How to install Entity Framework Core in your web application? In asp.net core we have meta-package and it does not have all dll it’s own it is only list of dependencies. Means it’s a list of dependencies. From 2.1 version of asp.net core we have no need to add an entity framework package. Our meta-package already contains this as part of the meta-package. List…

Read More