Blazor is a framework from Microsoft which makes .Net to run in the browser on top of web assembly. In this article we will be talking about usage of Blazor in a web application simply put pros and cons of using Blazor and different types of Blazor available for different scenarios.
Different Types of Blazor
There are 2 types of Blazor came from experiments, they are
- Client-side Blazor
- Server-side Blazor
Client-side Blazor works in the client side and the server-side Blazor works in the server side as the names suggest.
The original Blazor from experiments the status of the framework has been upgraded from experimental to preview.
Blazor works inside of .Net runtime on top of webAssembly so the code run directly in the browser
Blazor is an experimental technology so Microsoft created Razor components which has a syntax almost identical to Blazor
Razor ran logic in the server side but the server-side code had communication with the client-side code in real time using SignalR.
Razor components is called server-side Blazor and the matched the project structure to the Client-side Blazor.
Creating a single page application using Blazor
- First, we need to create a Blazor in the visual studio
- Then we have to configure the application in this panel where we have to specify the name of the project and the location of the project and its solution
- After that we need to select Blazor server app and then click create to create a single page application
- After creating a Blazor app open the file directory CMD and install Entity Framework 3.0 by running the following code
dotnet tool install –global dotnet-ef –version 3.0.0
- Then after this add the Entity Framework SQL server by running the following code
dotnet add package Microsoft.EntityFrameworkCore.SqlServer –version 3.0.0
- After creating the app launch it accepting the certificates that they need in order to launch the application, then the out put will look like something like this.
so there you have it with these simple steps we can easily create a single page application using Blazor with Entity Framework 3.0.