Advertisement
Guest User

Untitled

a guest
May 1st, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. namespace STUFV.DataLayer.Migrations
  2. {
  3. using DomainClasses;
  4. using System;
  5. using System.Data.Entity;
  6. using System.Data.Entity.Migrations;
  7. using System.Linq;
  8.  
  9. public sealed class Configuration : DbMigrationsConfiguration<STUFV.DataLayer.StufvContext>
  10. {
  11. public Configuration()
  12. {
  13. AutomaticMigrationsEnabled = true;
  14. AutomaticMigrationDataLossAllowed = true;
  15. }
  16.  
  17. protected override void Seed(STUFV.DataLayer.StufvContext context)
  18. {
  19. /*context.Events.AddOrUpdate(
  20. new Event
  21. {
  22. EventId = 29,
  23. Name = "Fuif2",
  24. Locatie = "Fuif",
  25. Adres = "Fuif",
  26. StartDateTime = DateTime.Now,
  27. EndDateTime = DateTime.Now.AddHours(6),
  28. },
  29. new Event
  30. {
  31. EventId = 2,
  32. Name = "Beestenfeest2",
  33. Locatie = "Hasselt",
  34. Adres = "Hoekstraat 1",
  35. StartDateTime = DateTime.Now,
  36. EndDateTime = DateTime.Now.AddHours(6),
  37. },
  38. new Event
  39. {
  40. EventId = 3,
  41. Name = "Beestenfeest3",
  42. Locatie = "Hasselt",
  43. Adres = "Hoekstraat 1",
  44. StartDateTime = DateTime.Now,
  45. EndDateTime = DateTime.Now.AddHours(6),
  46. }
  47. );
  48.  
  49. context.UserEventsSet.AddOrUpdate(
  50. new UserEvents
  51. {
  52. UserName = "admin@gmail.com",
  53. ParticipatingEvents = context.Events.Where(e => e.Name == "Beestenfeest").ToList(),
  54. },
  55. new UserEvents
  56. {
  57. UserName = "admin2@gmail.com",
  58. ParticipatingEvents = context.Events.Take(2).ToList(),
  59. // ParticipatingEvents = context.Events.ToList(),
  60. });
  61.  
  62. context.Categories.AddOrUpdate(
  63. new Category
  64. {
  65. CategoryId = 1,
  66. Name = "Fuif"
  67. });
  68. context.Categories.AddOrUpdate(
  69. new Category
  70. {
  71. CategoryId = 2,
  72. Name = "Festival"
  73. });
  74. context.Events.AddOrUpdate(
  75. new Event
  76. {
  77. EventId = 1,
  78. Name = "Beestenfeest",
  79. Locatie = "Hasselt",
  80. Adres = "Hoekstraat 1",
  81. StartDateTime = DateTime.Now,
  82. EndDateTime = DateTime.Now.AddHours(6),
  83. },
  84. new Event
  85. {
  86. EventId = 2,
  87. Name = "Nie Zat Nie Buiten",
  88. Locatie = "Genk",
  89. Adres = "Hoekstraat 1",
  90. StartDateTime = DateTime.Now.AddDays(1),
  91. EndDateTime = DateTime.Now.AddDays(1).AddHours(6),
  92. },
  93. new Event
  94. {
  95. EventId = 3,
  96. Name = "Fris Aan De Vis",
  97. Locatie = "Tongeren",
  98. Adres = "Hoekstraat 1",
  99. StartDateTime = DateTime.Now.AddDays(3),
  100. EndDateTime = DateTime.Now.AddDays(3).AddHours(6),
  101. },
  102. new Event
  103. {
  104. EventId = 4,
  105. Name = "Rock Werchter",
  106. Locatie = "Hasselt",
  107. Adres = "Hoekstraat 1",
  108. StartDateTime = DateTime.Now.AddDays(-2),
  109. EndDateTime = DateTime.Now.AddDays(-2).AddHours(6),
  110. },
  111. new Event
  112. {
  113. EventId = 5,
  114. Name = "Pukkepop",
  115. Locatie = "Hasselt",
  116. StartDateTime = DateTime.Now.AddDays(-6),
  117. EndDateTime = DateTime.Now.AddDays(-6).AddHours(6),
  118. });/**/
  119.  
  120. /*
  121. context.UserEventsList.AddOrUpdate(
  122. new UserEvents
  123. {
  124. UserId = 2,
  125. ParticipatingEvents = (from e in context.Events select e.EventId).ToArray(),
  126. OrganisedEvents = (from e in context.Events select e.EventId).ToArray(),
  127. });
  128.  
  129. context.Users.AddOrUpdate(
  130. new User
  131. {
  132. UserId = 1,
  133. Name = "jan",
  134. Password = "jan",
  135. },
  136. new User
  137. {
  138. UserId = 2,
  139. Name = "piet",
  140. Password = "piet",
  141. });/***/
  142.  
  143. // This method will be called after migrating to the latest version.
  144.  
  145. // You can use the DbSet<T>.AddOrUpdate() helper extension method
  146. // to avoid creating duplicate seed data. E.g.
  147. //
  148. // context.People.AddOrUpdate(
  149. // p => p.FullName,
  150. // new Person { FullName = "Andrew Peters" },
  151. // new Person { FullName = "Brice Lambson" },
  152. // new Person { FullName = "Rowan Miller" }
  153. // );
  154. //
  155. }
  156. }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement