Guest User

Untitled

a guest
Oct 13th, 2012
664
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public class DbInitializer : DropCreateDatabaseAlways<MenuEntities>
  2.     {
  3.         protected override void Seed(MenuEntities context)
  4.         {
  5.  
  6.             var statuses = new List<Status>
  7.             {
  8.                 new Status { Name = "Draft" },
  9.                 new Status { Name = "Live" },
  10.                 new Status { Name = "Invisible" },
  11.                 new Status { Name = "Discontinued" }
  12.             };
  13.             statuses.ForEach(a => context.Statuses.Add(a));
  14.  
  15.             var restaurants = new List<Restaurant>
  16.             {
  17.                 new Restaurant { Name = "Restaurant A",
  18.                                  Email = "restaurant@gmail.com",
  19.                                  Telephone = "01234567",
  20.                                  Status = statuses.Single(s => s.Name=="Draft"),
  21.                                  Menus = new List<Menu>
  22.                                  {
  23.                                      new Menu
  24.                                          { Name = "A La Carte",
  25.                                            Status = statuses.Single( s => s.Name == "Draft" )
  26.                                          },
  27.                                      new Menu
  28.                                          { Name = "Starters",
  29.                                            Status = statuses.Single(s => s.Name =="Draft")
  30.                                          }
  31.                                  }
  32.                 }
  33.             };
  34.  
  35.             // Multiplicity constraint violated. The role 'Menu_Status_Source' of the relationship 'LaCascadaWebApi.Models.Menu_Status' has multiplicity 1 or 0..1.
  36.             restaurants.ForEach(a => context.Restaurants.Add(a));
  37.             base.Seed(context);
  38.         }
  39.     }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×