Data Base And Models Of Projects Have Been Designed By DB First Approach
-
dotnet add package BCrypt.Net-Next dot net add packages Microsoft.EntityFrameworkCore dot net add packages Microsoft.EntityFrameworkCore.Design dot net add packages Microsoft.EntityFrameworkCore.Realtional dot net add packages Microsoft.EntityFrameworkCore.SqlServer dot net add packages Microsoft.EntityFrameworkCore.Tools dotnet add package Microsoft.Extensions.Caching.StackExchangeRedis dotnet add package Swashbuckle.AspNetCore
For Connecting To Your Own SQL Server You Must Change appsetting.json file Connection String For Example
"ConnectionString": "Data Source=.;Initial Catalog=WildDeer;Integrated Security=True;Trust Server Certificate=True"
//Data Source = . if we are in localhost
And Also Add SQL Server Service To Program.cs file
builder.Services.AddEntityFrameworkSqlServer().AddDbContext<WildDeerContext>(config =>
{
config.UseSqlServer("ConnectionString");
});
I Have Used Redis For Caching Approaches
After Installing StackExchangeRedis Package We Should Do Several Things In Program.cs File:
builder.Services.AddStackExchangeRedisCache(action => {
var connection = "localhost:6379"; //remember this port number it will be needed later
action.Configuration = connection;
});
Then We Will Use Docker For Our Approach
In CMD Or Package Manager Console If You Use Visual Studio Write This Command:
docker pull redis
Then
docker run -p 6379:6379 --name some-redis -d redis
6379 Is What We Determined In Program.cs File And some-redis Is Name Of Our Image, You Can Choose Whatever You Want
For Using API You Must Login As Admin Or HR : Username = Ali & Password = Ali
In WildDeerDB Foler Database Tables Are Represented In Scripts You Can Use This For Creating You Own Tables In MSS
In DockerFile I've Writed Needed Commands For Building Image
For Building Image You Should Write This Command In Application Directory
docker build -t <tagname> .
Now You Have Your Image On Docker And For Seeing This Write This Command
docker image ls
Now For Running Write This Command In Your Windows Or VPS That You've Got
docker run <tagname that you determinded before>