Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 2.24 KB | None | 0 0
  1. using System.Data.Entity;
  2. using System.Security.Claims;
  3. using System.Threading.Tasks;
  4. using Microsoft.AspNet.Identity;
  5. using Microsoft.AspNet.Identity.EntityFramework;
  6. using Dota2MK_Final.Models;
  7.  
  8. namespace Dota2MK_FinalPage.Models
  9. {
  10.     // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
  11.     public class ApplicationUser : IdentityUser
  12.     {
  13.         public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
  14.         {
  15.             // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
  16.             var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
  17.             // Add custom user claims here
  18.             return userIdentity;
  19.         }
  20.     }
  21.  
  22.     public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
  23.     {
  24.         public ApplicationDbContext()
  25.             : base("DefaultConnection", throwIfV1Schema: false)
  26.         {
  27.         }
  28.  
  29.         public DbSet<Country> Countries { get; set; }
  30.         public DbSet<PrizeType> PrizeTypes { get; set; }
  31.         public DbSet<Prize> Prizes { get; set; }
  32.         public DbSet<Player> Players { get; set; }
  33.         public DbSet<Team> Teams { get; set; }
  34.         public DbSet<Match> Matches { get; set; }
  35.         public DbSet<Tournament> Tournaments { get; set; }
  36.  
  37.         public static ApplicationDbContext Create()
  38.         {
  39.             return new ApplicationDbContext();
  40.         }
  41.  
  42.         protected override void OnModelCreating(DbModelBuilder modelBuilder)
  43.         {
  44.             modelBuilder.Entity<Match>()
  45.                   .HasRequired(m => m.Radiant)
  46.                   .WithMany(t => t.Matches)
  47.                   .HasForeignKey(m => m.RadiantId)
  48.                   .WillCascadeOnDelete(false);
  49.  
  50.             modelBuilder.Entity<Match>()
  51.                         .HasRequired(m => m.Dire)
  52.                         .WithMany(t => t.Matches)
  53.                         .HasForeignKey(m => m.DireId)
  54.                         .WillCascadeOnDelete(false);
  55.  
  56.             base.OnModelCreating(modelBuilder);
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement