A blog back-end based on ASP.NET Core 7 Rest API + EF Core + MariaDB + JWT Authorization
If you want a preview please visit here
You can install either MySQL or MariaDB:
sudo yum install mariadb-server
If you want to change database to SQL Server,
change the nuget package from Pomelo.EntityFrameworkCore.Mysql
to Microsoft.EntityFrameworkCore.SqlServer
:
dotnet remove package Pomelo.EntityFrameworkCore.Mysql
dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 7.0.2
And configure as it should be.
Change IP address to your local network address in Properties/launchSettings.json
:
"applicationUrl": "http://192.168.2.233:7084"
Change the IP address and port depends on your local network environment
builder.Services.AddCors(options =>
{
options.AddPolicy(name: "_myAllowSpecificOrigins",
policy =>
{
policy.WithOrigins("http://127.0.0.1:5173", "http://localhost:5173",
"http://127.0.0.1:5174", "http://localhost:5174", "http://192.168.2.233:5173")
.WithExposedHeaders("X-Pagination")
.SetIsOriginAllowed(x => _ = true)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
}
);
});
For other Linux distro/Windows, you can install any version of MariaDB/MySQL
var sqlVersion = new MariaDbServerVersion(new Version(5, 5, 68)); //change this to your database version
Configure your database connectionstring in appsettings.Development.json
for development, or appsettings.json
for production:
"ConnectionStrings": {
"DefaultConnection": "server=localhost;port=3306;database=techblog;user=root;password=pswd"
}
cd TechBlogCore.RestApi
dotnet ef database update
dotnet run
dotnet publish