#58 added owned entity for SocialNetworks that belongs to an ApplicationUser
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using Hutopy.Infrastructure.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Hutopy.Infrastructure.Data.Configurations;
|
||||
|
||||
public class ApplicationUserConfiguration : IEntityTypeConfiguration<ApplicationUser>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ApplicationUser> builder)
|
||||
{
|
||||
// Relationship between ApplicationUser and SocialNetworks
|
||||
builder
|
||||
.OwnsOne(u => u.SocialNetworks)
|
||||
.ToTable($"{nameof(ApplicationUser)}_SocialNetworks");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Hutopy.Domain.Entities;
|
||||
using Hutopy.Infrastructure.Identity;
|
||||
|
||||
namespace Hutopy.Infrastructure.Data.Configurations
|
||||
{
|
||||
public class UserTransactionConfiguration : IEntityTypeConfiguration<UserTransaction>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserTransaction> builder)
|
||||
{
|
||||
// Relationship between ApplicationUser and UserTransaction
|
||||
builder.HasOne<ApplicationUser>()
|
||||
.WithMany()
|
||||
.HasForeignKey(ut => ut.ApplicationUserId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Amount).HasPrecision(18, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user