Fix database schema
This commit is contained in:
parent
0d47f075db
commit
c01b6e8c77
6 changed files with 50 additions and 8 deletions
|
@ -6,6 +6,6 @@
|
|||
|
||||
public virtual ICollection<User>? Users { get; set; } = new HashSet<User>();
|
||||
|
||||
public virtual ICollection<Card>? Cards { get; set; } = new HashSet<Card>();
|
||||
public virtual ICollection<Column>? Columns { get; set; } = new HashSet<Column>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Column { get; set; }
|
||||
public int SenderId { get; set; }
|
||||
public int BoardId { get; set; }
|
||||
public int ColumnId { get; set; }
|
||||
|
||||
public virtual User Sender { get; set; }
|
||||
public virtual Board Board { get; set; }
|
||||
public virtual Column Column { get; set; }
|
||||
|
||||
public virtual ICollection<Comment> Comments { get; set; } = new HashSet<Comment>();
|
||||
}
|
||||
|
|
12
Entities/Column.cs
Normal file
12
Entities/Column.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace NG_2023_Kanban.Entities
|
||||
{
|
||||
public class Column : BaseEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int BoardId { get; set; }
|
||||
|
||||
public virtual Board Board { get; set; }
|
||||
|
||||
public virtual ICollection<Card>? Cards { get; set; } = new HashSet<Card>();
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
public bool IsAdmin { get; set; }
|
||||
|
||||
public virtual ICollection<Board>? Boards { get; set; } = new HashSet<Board>();
|
||||
public virtual ICollection<Card>? Cards { get; set; } = new HashSet<Card>();
|
||||
public virtual ICollection<Comment>? Comments { get; set; } = new HashSet<Comment>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,16 @@ namespace NG_2023_Kanban.EntityConfiguration
|
|||
builder.Property(x => x.Description).IsRequired();
|
||||
builder.Property(x => x.Description).HasMaxLength(100);
|
||||
|
||||
builder.Property(x => x.Column).IsRequired();
|
||||
builder.Property(x => x.Column).HasMaxLength(100);
|
||||
builder
|
||||
.HasOne(x => x.Sender)
|
||||
.WithMany(x => x.Cards)
|
||||
.HasForeignKey(x => x.SenderId)
|
||||
.HasPrincipalKey(x => x.Id);
|
||||
|
||||
builder
|
||||
.HasOne(x => x.Board)
|
||||
.HasOne(x => x.Column)
|
||||
.WithMany(x => x.Cards)
|
||||
.HasForeignKey(x => x.BoardId)
|
||||
.HasForeignKey(x => x.ColumnId)
|
||||
.HasPrincipalKey(x => x.Id);
|
||||
}
|
||||
}
|
||||
|
|
27
EntityConfiguration/ColumnConfiguration.cs
Normal file
27
EntityConfiguration/ColumnConfiguration.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using NG_2023_Kanban.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace NG_2023_Kanban.EntityConfiguration
|
||||
{
|
||||
public class ColumnConfiguration : IEntityTypeConfiguration<Column>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Column> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.Id);
|
||||
builder.Property(x => x.Id).IsRequired();
|
||||
|
||||
builder.Property(x => x.Name).IsRequired();
|
||||
builder.Property(x => x.Name).HasMaxLength(100);
|
||||
|
||||
builder.Property(x => x.Board).IsRequired();
|
||||
builder.Property(x => x.Board).HasMaxLength(100);
|
||||
|
||||
builder
|
||||
.HasOne(x => x.Board)
|
||||
.WithMany(x => x.Columns)
|
||||
.HasForeignKey(x => x.BoardId)
|
||||
.HasPrincipalKey(x => x.Id);
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue