Advertisement
cortez

EF Relations Example

Apr 4th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.65 KB | None | 0 0
  1. using SportsService.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace SportsService.Models
  8. {
  9.     public class Club
  10.     {
  11.         public int ID { get; set; }
  12.         public byte[] Logo { get; set; }
  13.         public string Name { get; set; }
  14.         public DateTime Established { get; set; }
  15.         public int PlayedMatches { get; set; }
  16.         public int Wins { get; set; }
  17.         public int Loss { get; set; }
  18.         public int Draw { get; set; }
  19.         public int GoalsConceived { get; set; }
  20.         public int GoalsScored { get; set; }
  21.         public int Points { get; set; }
  22.         public int LeaguePosition { get; set; }
  23.         public int CoachID { get; set; }
  24.         public int StadiumID { get; set; }
  25.         public int DivisionID { get; set; }
  26.         public string History { get; set; }
  27.         public int TitlesWon { get; set; }
  28.         public string TitlesWonYears { get; set; }
  29.         public int CupsWon { get; set; }
  30.         public string CupsWonYears { get; set; }
  31.         public int ChampionsLeaguesWon { get; set; }
  32.         public string ChampionsLeaguesWonYears { get; set; }
  33.         public int EuropaLeaguesWon { get; set; }
  34.         public string EuropaLeaguesWonYears { get; set; }
  35.  
  36.         public virtual Coach Coach{ get; set; }
  37.         public virtual Division Division { get; set; }
  38.         public virtual Stadium Stadium { get; set; }
  39.         public virtual ICollection<Player> Players { get; set; }
  40.  
  41.     }
  42.  
  43.     public class Coach
  44.     {
  45.         public int ID { get; set; }
  46.         public int ClubID { get; set; }
  47.         public int CountryID { get; set; }
  48.         public byte[] ProfileImage { get; set; }
  49.         public string Name { get; set; }
  50.         public int Age { get; set; }
  51.         public DateTime DateOfBirth { get; set; }
  52.         public string Nationality { get; set; }
  53.         public string Bio { get; set; }
  54.  
  55.         public virtual Club Club { get; set; }
  56.         public virtual Country Country { get; set; }
  57.     }
  58.  
  59.     public class ItemsDbContext : DbContext
  60.     {
  61.         public ItemsDbContext()
  62.             : base("ItemsConnection")
  63.         { }
  64.  
  65.         public DbSet<Club> Clubs { get; set; }
  66.         public DbSet<Coach> Coaches { get; set; }
  67.         public DbSet<Player> Players { get; set; }
  68.         public DbSet<Division> Divisions { get; set; }
  69.         public DbSet<GamePlayed> Matches { get; set; }
  70.         public DbSet<News> News { get; set; }
  71.  
  72.         protected override void OnModelCreating(DbModelBuilder modelBuilder)
  73.         {
  74.             //modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement