Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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