(1) Getting Started MasaFramework Tutorial

(1) Getting Started MasaFramework Tutorial

first understand MasaFrameworkwhat is

MasaFrameworkIs a .Net6.0back-end framework based on , can be used to develop web applications, WPF projects, console projects

In fact, it is MasaFrameworka package that provides many functions. It is very powerful. It supports Dapr very well. If you want to try Dapr, you can try it.MasaFramework

Then we started to use it MasaFrameworkand entered the actual combat

  1. Install MasaFrameworkproject templates

    dotnet new --install Masa.Template
    

    In this way, the installation is successful

  2. create project

    Open a directory, open the console to create a template project, create a mfDemoproject template

    dotnet new masafx --name mfDemo
    

    In this way, the creation is complete, open the solution

  1. Project structure analysis

We can see the project structure after opening the solution

The project is divided into src/ApiGateways, src/Contracts, src/Services, and four layers. At this time, many people may have doubts about why it is different src/Webfrom the traditional architecture design. In fact, this is the beauty of the framework.AbpMasaFramework

src/ApiGatewaysContains the interface implementation for external use, which is equivalent to that I can src/ApiGatewaysdirectly src/Webuse the given front-end project. The advantage of this is to reduce the dependency of the front-end project and quickly connect to the interface

src/ContractsContains the basic model, and some shared things, src/Contractsis pure, without any dependencies, so src/ApiGatewaysand src/Serviceswill directly depend on src/Contracts, for sharing Moduleor other things,

src/ServicesIt contains the specific business and implementation, and containsHost

Application​ Include business processing or event processing in

MiniApiWhat should appear if you are not usingControllers

In fact, it is recommended to use MiniApi, because the two implementations are different, resulting MiniApiin a Controllersbetter performance comparison

InfrastructureIn is the infrastructure of the project. Looking at the picture, we found that Entityand Middleware, Repository, DbContextare in the infrastructure

MasaFrameworkThe best design is to simplify the complexity of the project and soften it into one project. If you just use it MasaFramework, don't split it. If you split it, it MasaFrameworkdoesn't match the design itself. But if you are a skilled boss, When I didn't say it, MasaFrameworkplease be sure to use the design of your own framework when you are just getting started

src/WebThis is our actual front-end project.

The default template created provides Blazor Servermode projects, which can be split into three-tier projects mfDemo.Shared mfDemo.Serverand mfDemo.WebAssemblythree-tier project architecture.

mfDemo.SharedIt can be understood as all functions such as all implementations and interfaces of the project,

mfDemo.ServerIn fact, it is a Blazor Servershell for hosting mfDemo.Sharedprojects

mfDemo.WebAssemblyIn fact, it is also a Blazor WebAssemblyshell for hosting mfDemo.Sharedprojects

In this way, our project can support Blazor Serverand Blazor WebAssemblytwo modes,

end

Through the above, we can basically MasaFrameworkunderstand the project structure clearly, and also know MasaFrameworkthe design,

It is currently MasaFrameworkthe first entry, I will continue to learn MasaFrameworkand share it with you

Sharing from token

MASA Framework

Learning exchange: 737776595

Guess you like

Origin blog.csdn.net/xiaohucxy/article/details/129483939