SunJian/WebApi/Program.cs

43 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using WebApi.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// builder.Services.AddIdentityApiEndpoints<IdentityUser>();
// builder.Services.AddIdentity<IdentityUser,IdentityRole>();
builder.Services.AddDbContext<ApplicationIdentityDbContext>(options => options.UseSqlite());
builder.Services.AddDbContext<DictionaryDbContext>();
builder.Services.AddAuthorization();
builder.Services.AddIdentityApiEndpoints<IdentityUser>().AddEntityFrameworkStores<ApplicationIdentityDbContext>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
// app.UseHttpsRedirection();
app.MapIdentityApi<IdentityUser>();
app.UseAuthorization();
app.MapControllers();
app.Run();