Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Decouple Account class from EF Core Identity #668

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Application/Common/Interfaces/IApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Hippo.Application.Common.Interfaces;

public interface IApplicationDbContext
{
DbSet<Account> Accounts { get; }

DbSet<App> Apps { get; }

DbSet<Certificate> Certificates { get; }
Expand Down
8 changes: 8 additions & 0 deletions src/Core/Entities/Account.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Hippo.Core.Entities;

public class Account
{
public Guid Id { get; set; }

public string? UserName { get; set; }
}
6 changes: 4 additions & 2 deletions src/Infrastructure/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using Hippo.Core.Common;
using Hippo.Core.Entities;
using Hippo.Core.Events;
using Hippo.Infrastructure.Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace Hippo.Infrastructure.Data;

public class ApplicationDbContext : IdentityDbContext<Account>, IApplicationDbContext
public class ApplicationDbContext : IdentityDbContext<IdentityUser>, IApplicationDbContext
{
private readonly ICurrentUserService _currentUserService;

Expand All @@ -32,6 +32,8 @@ public ApplicationDbContext(
_dateTime = dateTime;
}

public DbSet<Account> Accounts => Set<Account>();

public DbSet<App> Apps => Set<App>();

public DbSet<Certificate> Certificates => Set<Certificate>();
Expand Down
3 changes: 1 addition & 2 deletions src/Infrastructure/Data/ApplicationDbContextSeed.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using Hippo.Infrastructure.Identity;
using Microsoft.AspNetCore.Identity;

namespace Hippo.Infrastructure.Data;

public static class ApplicationDbContextSeed
{
public static async Task SeedIdentityRolesAsync(UserManager<Account> userManager, RoleManager<IdentityRole> roleManager)
public static async Task SeedIdentityRolesAsync(UserManager<IdentityUser> userManager, RoleManager<IdentityRole> roleManager)
{
var administratorRole = new IdentityRole("Administrator");

Expand Down
Loading