i'm not sure what i'm doing
This commit is contained in:
parent
950babb68c
commit
35331a87f1
7 changed files with 41 additions and 13 deletions
|
|
@ -1,3 +1,8 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SurveyBackend.Core.Models;
|
||||
using SurveyBackend.Infrastructure.Data;
|
||||
|
||||
namespace SurveyBackend;
|
||||
|
||||
public class Program
|
||||
|
|
@ -9,6 +14,15 @@ public class Program
|
|||
// Add services to the container.
|
||||
builder.Services.AddAuthorization();
|
||||
|
||||
builder.Services.AddDbContext<DataContext>(options =>
|
||||
{
|
||||
options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"));
|
||||
});
|
||||
|
||||
builder.Services.AddIdentity<User, IdentityRole<int>>(options => { })
|
||||
.AddEntityFrameworkStores<DataContext>()
|
||||
.AddDefaultTokenProviders();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
|
|
|||
|
|
@ -9,7 +9,13 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.2"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SurveyBackend.Core\SurveyBackend.Core.csproj" />
|
||||
<ProjectReference Include="..\SurveyBackend.Infrastructure\SurveyBackend.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -4,5 +4,8 @@
|
|||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Data Source=Application.db"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,5 +5,8 @@
|
|||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Data Source=Application.db"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace SurveyBackend.Core.Models;
|
||||
|
||||
public class User
|
||||
public class User : IdentityUser<int>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Email { get; set; }
|
||||
|
||||
public byte[] PasswordSalt { get; set; }
|
||||
public byte[] PasswordHash { get; set; }
|
||||
|
||||
public ICollection<Group> Groups { get; set; }
|
||||
}
|
||||
|
|
@ -6,4 +6,9 @@
|
|||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.3.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SurveyBackend.Core.Models;
|
||||
|
||||
namespace SurveyBackend.Infrastructure.Data;
|
||||
|
||||
public class DataContext : DbContext
|
||||
public class DataContext : IdentityDbContext<User, IdentityRole<int>, int>
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<Group> Groups { get; set; }
|
||||
|
||||
public DataContext(DbContextOptions<DataContext> options) : base(options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue