-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
30 lines (19 loc) · 846 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Microsoft.EntityFrameworkCore;
using RepositoryPattern_MySQL_Youtube.Models;
using RepositoryPattern_MYSQL_Youtube.Data.MusicRepo;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
// Add connection string
var connectionString = builder.Configuration.GetConnectionString("DbConnection");
// Set the connectionString to AddDbContext
builder.Services.AddDbContext<AppDbContext>(options=>options.UseMySql(connectionString,ServerVersion.AutoDetect(connectionString)));
// Reguster service
builder.Services.AddScoped<IMusicService,MusicService>();
// Register Automapper
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
var app = builder.Build();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();