public override void Configure(EntityTypeBuilder <Competition> builder)
        {
            base.Configure(builder);

            //Fields
            builder.Property(x => x.Date).IsRequired();
            builder.Property(x => x.Description);
            builder.Property(x => x.Name).IsRequired();
            builder.Property(x => x.CompetitionGender).IsRequired();
            builder.Property(x => x.CompetitionLevel).IsRequired();
            builder.Property(x => x.CompetitionSport).IsRequired();
            builder.Property(x => x.CompetitionType).IsRequired();
            builder
            .HasOne(x => x.Organizer)
            .WithMany()
            .HasForeignKey("FK_Competition_Club_Organizer")
            .IsRequired()
            .OnDelete(DeleteBehavior.Restrict);

            builder.OwnsOne(
                navigationExpression: x => x.Address,
                buildAction: AddressMapBuilder.GetAddressBuilderAction <Competition>()
                );


            //Index
            builder.HasIndex(x => new { x.OrganizerId }).HasName("IX_Competition_Club_Organizer");
            builder.HasIndex(x => new { x.Date }).HasName("IX_Competition_Date");
        }
Exemplo n.º 2
0
        public override void Configure(EntityTypeBuilder <Club> builder)
        {
            base.Configure(builder);

            //Fields;
            builder.Property(x => x.Name).IsRequired();
            builder.Property(x => x.ShortName);
            builder.OwnsOne(
                navigationExpression: x => x.Address,
                buildAction: AddressMapBuilder.GetAddressBuilderAction <Club>()
                );


            //Index
            builder.HasIndex(x => x.Name).HasName("IX_Club_Name");
            builder.HasIndex(x => x.ShortName).HasName("IX_Club_ShortName");
        }