Thoughts on .Net & Coding

.Net Articles, tutorials, reviews, code and more...

  • Create database from model using Entity Framework Core and ASPNET Core

    While working with Entity Framework Core and ASP.NET Core you typically create EF Core model consisting of a custom DbContext and entity classes. If your database already exists, it can be mapped with the EF Core model. However, if the database doesn't exist already, you would want it to be created. Of course, you can create the database manually by looking at the EF Core model and creating tables accordingly. Wouldn't it be nice if the database gets created automatically for you based on the EF Core model your created? To that end this article discusses just that.

  • Use AutoMapper to map one object to another in ASP.NET Core

    While developing ASP.NET Core web applications you often need to transfer data residing in one object into another. You can accomplish this task manually by setting properties of the target object with the values from the source object. But wouldn't it be nice if this task can be automated? That's what the AutoMapper library is about. In this article you learn to use AutoMapper in an ASP.NET Core application.

  • Download and Upload Google Drive Files in ASPNET Core

    In the previous article we displayed a list of files from Google Drive. By now you know how to configure a Google API project and establish a connection with your Google drive. In this part you will build on top of what you learned in the previous part. Firstly you will provide Download functionality to the list of files displayed in the browser. The downloaded file(s) is saved in the wwwroot folder and can be used by your application for further processing. Secondly, you will also learn to upload files from your ASP.NET Core web application to the Google drive.

  • Get list of files from Google Drive in ASPNET Core

    Google drive offers a convenient way to organize and store your files in cloud. It has a rich user web interface that can be used to work with the files and folders. At times, however, you need to deal with the files stored in Google drive through an ASP.NET Core application. Consider a situation where you want to import files from user's Google drive into your web application for certain processing. Now this requires that you get a list of files from the user's Google drive and manipulate them as and when necessary. To that end this article shows how to use Google Drive API in an ASP.NET Core application to get a list of files from the Google drive.

  • Use Google Charts in AspNet Core

    At time your ASP.NET Core web applications want to display certain data in the form of bar chart or pie chart. Although there are plenty third-party components and libraries that you can use to accomplish this task, Google Charts is a simple yet feature rich client side option. To that end this article shows how Google Charts can be used to render simple bar charts and pie charts.

  • Use IHttpClientFactory to invoke Web API in ASP.NET Core

    If you have worked with ASP.NET Core Web APIs before, chances are you used HttpClient to invoke them. Although instantiating HttpClient directly is a common way of using it, there is a better alternative. Rather than instanting HttpClient yourself you can use IHttpClientFactory to obtain an instance of HttpClient. The HttpClient object thus obtained can be used to invoke the Web API. In this article I discuss three ways to obtain an HttpClient instance using IHttpClientFactory.

  • .NET Standard for Absolute Beginners

    If you are a beginner in ASP.NET Core chances are at some point in time you stumbled upon this - .NET Standard. You probably wondered what it is and how is it different than .NET Framework and .NET Core. Although you might have heard this term, while developing your ASP.NET Core apps you might not have bothered about it at all. This might have made you wonder even more as to what's the use of .NET Standard if it's not actively used while developing your apps. You might have also felt bit confusing about the version number that accompanies .NET Standard. This article attempts to explain all these questions about .NET Standard from beginner's perspective. My aim is to quickly enable you to grasp the concept and utility of .NET Standard and I also provide pointers for more detailed understanding.

  • CRUD using gRPC, EF Core, and ASPNET Core (Part - 3)

    In Part -1 and Part - 2 of this article you created EmployeeCRUD service definition using Protocol Buffer language and also implemented it in EmployeeCRUDService class. So, our gRPC service is now ready. In this part we will consume the service in an ASP.NET Core MVC application. Begin by opening the GrpcService1 project you created earlier. Add a new ASP.NET Core MVC application in the same solution. Then copy the Protos folder from the GrpcService1 project into the newly created MVC application. At this stage your Solution Explorer will look like this.

  • CRUD using gRPC, EF Core, and ASP.NET Core (Part - 2)

    In Part -1 of this article you created EmployeeCRUD service definition using Protocol Buffer language. The EmployeeCRUD.proto file and EF Core model is now ready. In this part you will create the EmployeeCRUD service based on the structure defined in the .proto file. To begin, open the project created in Part -1 and expand the Services folder. Rename the service file to EmployeeCRUDService.cs. At this point the Solutions Explorer will look like this.