-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventConfiguration.cs
More file actions
43 lines (40 loc) · 1.46 KB
/
Copy pathEventConfiguration.cs
File metadata and controls
43 lines (40 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Eventz.Domain.Entitites;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Eventz.Infrastructure.Configurations
{
public class EventConfiguration : IEntityTypeConfiguration<Event>
{
public void Configure(EntityTypeBuilder<Event> builder)
{
builder.ToTable("Events");
builder.HasKey(e => e.Id);
builder.Property(e => e.Name)
.IsRequired()
.HasMaxLength(256);
builder.Property(e => e.Description)
.IsRequired()
.HasMaxLength(256);
builder.Property(e => e.StartDate).IsRequired();
builder.Property(e => e.EndDate)
.IsRequired();
builder.Property(e => e.IsPublic).IsRequired().HasDefaultValue(false);
builder.Property(e => e.CategoryId).IsRequired();
builder.Property(e => e.CategoryId).IsRequired();
//relations
builder.HasOne(e => e.Venue)
.WithMany(v => v.Events)
.HasForeignKey(e => e.VenueId)
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(e => e.Category)
.WithMany(v => v.Events)
.HasForeignKey(e => e.CategoryId)
.OnDelete(DeleteBehavior.Restrict);
}
}
}