EnVisageOnline/Main/Source/IntegrationTests/Models/Mapping/User2TeamMap.cs

35 lines
1.0 KiB
C#

using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
namespace IntegrationTests.Models.Mapping
{
public class User2TeamMap : EntityTypeConfiguration<User2Team>
{
public User2TeamMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.UserId)
.IsRequired()
.HasMaxLength(128);
// Table & Column Mappings
this.ToTable("User2Team");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.UserId).HasColumnName("UserId");
this.Property(t => t.TeamId).HasColumnName("TeamId");
// Relationships
this.HasRequired(t => t.AspNetUser)
.WithMany(t => t.User2Team)
.HasForeignKey(d => d.UserId);
this.HasRequired(t => t.Team)
.WithMany(t => t.User2Team)
.HasForeignKey(d => d.TeamId);
}
}
}