(1) Getting Started MasaFramework Tutorial
first understand MasaFramework
what is
MasaFramework
Is a .Net6.0
back-end framework based on , can be used to develop web applications, WPF projects, console projects
In fact, it is MasaFramework
a 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 MasaFramework
and entered the actual combat
-
Install
MasaFramework
project templatesdotnet new --install Masa.Template
In this way, the installation is successful
-
create project
Open a directory, open the console to create a template project, create a
mfDemo
project templatedotnet new masafx --name mfDemo
In this way, the creation is complete, open the solution
- 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/Web
from the traditional architecture design. In fact, this is the beauty of the framework.Abp
MasaFramework
src/ApiGateways
Contains the interface implementation for external use, which is equivalent to that I can src/ApiGateways
directly src/Web
use 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/Contracts
Contains the basic model, and some shared things, src/Contracts
is pure, without any dependencies, so src/ApiGateways
and src/Services
will directly depend on src/Contracts
, for sharing Module
or other things,
src/Services
It contains the specific business and implementation, and containsHost
Application
Include business processing or event processing in
MiniApi
What should appear if you are not usingControllers
In fact, it is recommended to use MiniApi
, because the two implementations are different, resulting MiniApi
in a Controllers
better performance comparison
Infrastructure
In is the infrastructure of the project. Looking at the picture, we found that Entity
and Middleware
, Repository
, DbContext
are in the infrastructure
MasaFramework
The 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 MasaFramework
doesn't match the design itself. But if you are a skilled boss, When I didn't say it, MasaFramework
please be sure to use the design of your own framework when you are just getting started
src/Web
This is our actual front-end project.
The default template created provides Blazor Server
mode projects, which can be split into three-tier projects mfDemo.Shared
mfDemo.Server
and mfDemo.WebAssembly
three-tier project architecture.
mfDemo.Shared
It can be understood as all functions such as all implementations and interfaces of the project,
mfDemo.Server
In fact, it is a Blazor Server
shell for hosting mfDemo.Shared
projects
mfDemo.WebAssembly
In fact, it is also a Blazor WebAssembly
shell for hosting mfDemo.Shared
projects
In this way, our project can support Blazor Server
and Blazor WebAssembly
two modes,
end
Through the above, we can basically MasaFramework
understand the project structure clearly, and also know MasaFramework
the design,
It is currently MasaFramework
the first entry, I will continue to learn MasaFramework
and share it with you
Sharing from token
Learning exchange: 737776595