public SeedVisibility(string versionID, PGDAL.PGModel.ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Visibility"; SeedStart(); if (SeedCanRun) { foreach(string v in visibilities) { UVisibility vb = new UVisibility(v); if (!db.Visibilities.Where(w => w.ColLGCls == v || w.ColMDCls == v || w.ColSMCls == v || w.ColXSCls == v).Any()) { vb.VisibilityID = Guid.NewGuid(); db.Visibilities.Add(vb); } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public SeedThemes(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Themes"; SeedStart(); if (SeedCanRun) { List<UTheme> Themes = UProvider.GetList<UTheme>("Theme").ToList(); if(Themes.Count > 0) { foreach(UTheme t in Themes) { UTheme tmp = new UTheme(t); if (!Db.Themes.Where(w => w.UmbracoID == t.UmbracoID).Any()) { t.ThemeID = Guid.NewGuid(); Db.Themes.Add(t); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public SeedCountries(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { InitCountryDict(); SeedName = "Countries"; SeedStart(); if (SeedCanRun) { List<UCountry> results = UProvider.GetList<UCountry>("Country").ToList(); List<UCountry> notInDict = getNotInDict(results); foreach (KeyValuePair<string,string> country in CDictionary) { UCountry tmp = new UCountry() { CountryID = Guid.NewGuid(), Name = country.Value, CultureIsoName = country.Key, CreateDate = DateTime.Now, CreatorName = "DBMigrator", IsPublished = true }; if (results.Where(w => w.CultureIsoName.ToLower() == country.Key.ToLower() && w.Name == country.Value).Any()) { tmp.UmbracoID = results.Where(w => w.CultureIsoName.ToLower() == country.Key.ToLower() && w.Name == country.Value).FirstOrDefault().UmbracoID; } Db.Countries.Add(tmp); } foreach(UCountry c in notInDict) { c.CountryID = Guid.NewGuid(); c.CreatorName = "Umbraco"; c.IsPublished = true; Db.Countries.Add(c); } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } catch(Exception ex) { throw ex; } } else { SeedFinished(true); } }
public SeedFestivals(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Festivals"; SeedStart(); if (SeedCanRun) { List<UFestival> results = UProvider.GetList<UFestival>("Festival").ToList(); if (results.Count > 0) { foreach (UFestival r in results) { if (!db.Festivals.Where(w => w.UmbracoID == r.UmbracoID).Any()) { r.FestivalID = Guid.NewGuid(); UFestival tmp = new UFestival(r); tmp.IsPublished = true; if (tmp.Genres != null) { foreach (UGenre tmpGenre in tmp.Genres) { UGenre dbGenre = Db.Genres.Where(w => w.UmbracoID == tmpGenre.UmbracoID).First(); Db.G2F.Add(new UGenre2UFestival { G2FID = Guid.NewGuid(), FestivalID = tmp.FestivalID, GenreID = dbGenre.GenreID }); } tmp.Genres = null; } UCountry dbCountry = Db.Countries.Where(w => w.UmbracoID == r.Country.UmbracoID).First(); tmp.CountryID = dbCountry.CountryID; tmp.Country = null; if (r.Artists != null) { foreach (UArtist tmpArtist in tmp.Artists) { UArtist dbArtist = db.Artists.Where(w => w.UmbracoID == tmpArtist.UmbracoID).First(); db.A2F.Add(new UArtist2UFestival { A2FID = Guid.NewGuid(), ArtistID = dbArtist.ArtistID, FestivalID = tmp.FestivalID }); } tmp.Artists = null; } Db.Festivals.Add(tmp); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public SeedBanners(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Banners"; SeedStart(); if (SeedCanRun) { List<UBanner> results = UProvider.GetList<UBanner>("Banner").ToList(); if (results.Count > 0) { foreach (UBanner r in results) { UBanner tmp = new UBanner(r); tmp.IsPublished = true; if (!Db.Banners.Where(w => w.UmbracoID == tmp.UmbracoID).Any()) { UVisibility tmpVis = new UVisibility(r.visibility); UVisibility vis = Db.Visibilities.Where(w => w.ColLGCls == tmpVis.ColLGCls).FirstOrDefault(); tmp.Genres = new List<UGenre>(); tmp.BannerID = r.BannerID = Guid.NewGuid(); tmp.Visibility = null; tmp.VisibilityID = vis.VisibilityID; if (tmp.CustomerIntID != null) { int uID = int.Parse(tmp.CustomerIntID); UCustomer customer = Db.Customers.AsNoTracking().Where(w => w.UmbracoID == uID).FirstOrDefault(); tmp.CustomerID = customer.CustomerID; } else { throw new Exception("Banner has no customero"); } tmp.Genres = null; Db.Banners.Add(tmp); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public SeedBase(string SeedVersion, ContentModel db, UmbracoProvider provider) { helper = new DataHelper(); mapper = new EntityMapper(helper); UProvider = provider; //IMPORTANT: REMOVE Guid.NewGuid() from seed version ID and change it to Guid.Parse(SeedVersion); SeedVersionID = Guid.Parse(SeedVersion); Db = db; if (Db.SeedVersions.Find(SeedVersionID) == null) { SeedCanRun = true; } else { SeedCanRun = false; } }
public SeedRoles(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { if (SeedCanRun) { SeedStart(); Permission EndUser = Db.Permissions.Where(w => w.PermissionKey == "END_USER").FirstOrDefault(); Role role = new Role() { RoleID = Guid.NewGuid(), Name = "END_USER", }; role.Permissions.Add(EndUser); Db.Roles.Add(role); Db.SaveChanges(); SeedFinished(true); } }
public SeedTruncate(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Truncate"; SeedStart(); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "SeedVersions")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UArtist2UFestival")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UGenre2UArtist")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UGenre2UFestival")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UBanners")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UNews")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UArtists")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UFestivals")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UVisibilities")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UAnnouncements")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UCustomers")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UCountries")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UGenres")); Db.Database.ExecuteSqlCommand(string.Format("DELETE FROM \"dbo\".\"{0}\"", "UThemes")); SeedFinished(true); }
public SeedNews(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "News"; SeedStart(); if (SeedCanRun) { List<UNews> results = UProvider.GetList<UNews>("News").ToList(); if (results.Count > 0) { foreach (UNews r in results) { UNews tmp = new UNews(r); if (!Db.News.Where(w => w.UmbracoID == tmp.UmbracoID).Any()) { tmp.NewsID = Guid.NewGuid(); tmp.Genres = null; Db.News.Add(tmp); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public SeedAnnouncements(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID,db,provider) { SeedName = "Announcements"; SeedStart(); if (SeedCanRun) { List<UAnnouncement> results = UProvider.GetList<UAnnouncement>("Announcement").ToList(); if (results.Count > 0) { foreach (UAnnouncement r in results) { UAnnouncement tmp = new UAnnouncement(r); tmp.IsPublished = true; if (!Db.Announcements.Where(w => w.UmbracoID == tmp.UmbracoID).Any()) { r.AnnouncementID = Guid.NewGuid(); Db.Announcements.Add(r); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public SeedCustomers(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Customers"; SeedStart(); if (SeedCanRun) { List<UCustomer> results = UProvider.GetList<UCustomer>("Customer").ToList(); if (results.Count > 0) { foreach (UCustomer r in results) { UCustomer tmp = new UCustomer(r); if (!Db.Customers.Where(w => w.UmbracoID == r.UmbracoID).Any()) { r.CustomerID = Guid.NewGuid(); Db.Customers.Add(r); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public UmbracoProviderTest() { _Helper = new DataHelper(); _Mapper = new EntityMapper(_Helper); _Provider = UmbracoProvider.GetInstance(_Mapper, "nl-NL"); }
public SeedMedia(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { if (this.SeedCanRun) { Db = db; obsoleteMedia = new List<UObsoleteMedia>(); GetObsoleteUmbracoMedia(); SeedName = "Media"; if (SeedCanRun) { SeedStart(); MediaDirectory defaultDir = new MediaDirectory { Name = "Media", AuthorID= Guid.Parse("BD808F49-DEE0-4EC4-9024-DEC2A716948A"), Created = DateTime.Now, Modified =null, DirectoryID = Guid.Parse("710FE0A0-8894-40DB-8D7D-2FCBD7BA14CF"), ParentID = null }; if (Db.MediaDirectories.Find(defaultDir.DirectoryID.Value) == null) { Db.MediaDirectories.Add(defaultDir); } MediaDirectory obsoleteDir = new MediaDirectory { Name = "Obsolete", AuthorID = Guid.Parse("BD808F49-DEE0-4EC4-9024-DEC2A716948A"), Created= DateTime.Now, Modified=null, ParentID = defaultDir.DirectoryID.Value, DirectoryID = Guid.Parse("19D0268E-4ACA-41F5-BC14-77DC4C1343CD") }; if (Db.MediaDirectories.Find(obsoleteDir.DirectoryID.Value) == null) { Db.MediaDirectories.Add(obsoleteDir); } foreach (UObsoleteMedia media in obsoleteMedia) { if (media == null) { throw new Exception("MEDIA IS NULL"); } if (Db == null) { throw new Exception("DB IS NULL"); } if (obsoleteDir == null || defaultDir == null) { throw new Exception("ONE OF THE DIRECTORY OBJ ARE NULL"); } if (Db.Media == null) { throw new Exception("DB MEDIA NULL ERRROR"); } if (media.DataNVarchar != null) { if (media.ContentNodeID != null) { Shared.Entities.Media m = new Shared.Entities.Media(); m.Name = media.DataNVarchar.Split('/').Last(); m.MediaID = Guid.NewGuid(); m.DirectoryID = obsoleteDir.DirectoryID; m.FileName = media.DataNVarchar; m.ObsoleteID = media.ContentNodeID; m.FileMimeType = "none"; m.Created = DateTime.Now; m.Modified = null; m.AuthorID = Guid.Parse("BD808F49-DEE0-4EC4-9024-DEC2A716948A"); Db.Media.Add(m); m = new FC.Shared.Entities.Media(); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } } }
public SeedGenres(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Genres"; SeedStart(); if (SeedCanRun) { List<UGenre> genres = UProvider.GetList<UGenre>("Genre").Distinct().ToList(); foreach(UGenre g in genres) { UGenre baseGenre = new UGenre(g); baseGenre.IsPublished = true; if (!Db.Genres.Where(w => w.UmbracoID == g.UmbracoID).Any()) { baseGenre.GenreID = Guid.NewGuid(); baseGenre.ParentID = null; if (baseGenre.Theme != null) { if (!db.Genres.Where(w => w.UmbracoID == baseGenre.UmbracoID).Any()) { if (g.Children != null) { if (db.Themes.Where(w => w.UmbracoID == baseGenre.Theme.UmbracoID).Any()) { baseGenre.ThemeID = Db.Themes.AsNoTracking().Where(w=>w.UmbracoID == baseGenre.Theme.UmbracoID).First().ThemeID; baseGenre.ParentID = null; baseGenre.Children = null; baseGenre.Theme = null; Db.Genres.Add(baseGenre); } } } } } else { UGenre updated = Db.Genres.AsNoTracking().Where(w => w.UmbracoID == g.UmbracoID).First(); baseGenre.GenreID = updated.GenreID; baseGenre.Children = null; baseGenre.Theme = null; Db.Entry<UGenre>(baseGenre).State = System.Data.Entity.EntityState.Modified; } } try { Db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } foreach (UGenre g in genres) { UGenre baseGenre = new UGenre(g); if (g.Children != null) { foreach (UGenre child in baseGenre.Children) { UGenre tmpChild = new UGenre(child); if (!Db.Genres.Where(w => w.UmbracoID == child.UmbracoID).Any()) { UTheme activeTheme = new UTheme(); if (child.Theme != null) { activeTheme = Db.Themes.AsNoTracking().Where(w => w.UmbracoID == child.Theme.UmbracoID).First(); } else { activeTheme = Db.Themes.AsNoTracking().Where(w => w.Name == "Default").First(); } tmpChild.ThemeID = activeTheme.ThemeID; tmpChild.GenreID = Guid.NewGuid(); Guid? parentId = Db.Genres.AsNoTracking().Where(w => w.UmbracoID == baseGenre.UmbracoID).First().GenreID; tmpChild.Theme = null; tmpChild.ParentID = parentId; Db.Genres.Add(tmpChild); } } } } try { Db.SaveChanges(); SeedFinished(true); } catch(System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public SeedArtists(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "Artists"; SeedStart(); if (SeedCanRun) { List<UArtist> artists = UProvider.GetList<UArtist>("Artist").ToList(); if (artists.Count > 0) { foreach (UArtist a in artists) { try { UArtist tmp = new UArtist(a); tmp.IsPublished = true; if (!Db.Artists.Where(w => w.UmbracoID == tmp.UmbracoID).Any()) { tmp.ArtistID = Guid.NewGuid(); if (a.Country != null) { UCountry country = Db.Countries.Where(w => w.UmbracoID == a.Country.UmbracoID).FirstOrDefault(); tmp.CountryID = country.CountryID; tmp.Country = null; List<UGenre> tmpList = new List<UGenre>(); foreach (UGenre genre in a.Genres) { UGenre tmpGenre = db.Genres.Where(w => w.UmbracoID == genre.UmbracoID).First(); if (!Db.G2A.Where(w => Db.Artists.Select(s => s).Where(w2 => w2.UmbracoID == tmp.UmbracoID).Select(s2 => s2.ArtistID).ToList().Contains(w.ArtistID) && w.GenreID == tmpGenre.GenreID).Any()) { Db.G2A.Add(new UGenre2UArtist { G2AID = Guid.NewGuid(), ArtistID = tmp.ArtistID, GenreID = tmpGenre.GenreID }); } } tmp.Genres = null; Db.Artists.Add(tmp); } else { throw new Exception("Country for artist " + a.Name + " was null"); } } } catch(Exception ex) { throw ex; } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } catch(Exception ex) { throw ex; } } else { SeedFinished(true); } }
public SeedApplicationUsers(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { if (SeedCanRun) { this.SeedStart(); //Store MD5 passwords. MD5 md5 = System.Security.Cryptography.MD5.Create(); string password = GetMd5Hash(md5, "Welcome@1"); string code = GetMd5Hash(md5, "68320"); string passwordImgHandler = GetMd5Hash(md5, "C0EADCF2#37A2!412D$BDB7@0559BB1C1EE4"); string codeImgHandler = GetMd5Hash(md5, "201610110304"); md5.Dispose(); ApplicationUser developer = new ApplicationUser() { UserActivated = true, UserAddress = "Wolfsklauwstraat 3", UserAddressNR = "3", UserEmailAddress = "*****@*****.**", UserFacebookID = "jahfyah026", UserFirstname = "Wesley", UserMiddlename = "van der", UserLastname = "Meer", UserID = Guid.Parse("BD808F49-DEE0-4EC4-9024-DEC2A716948A"), UserTwitterID = null, UserInstagramID = null, UserName = "******", UserPassword = password, UserCode = code, UserPhoneNumber = "0031642775321", UserProfileIMG = null, UserCount = 1, }; ApplicationUser FCImageHandler = new ApplicationUser() { UserActivated = true, UserAddress = "Wolfsklauwstraat 3", UserAddressNR = "3", UserEmailAddress = "*****@*****.**", UserFacebookID = "", UserFirstname = "Wesley", UserMiddlename = "van der", UserLastname = "Meer", UserID = Guid.NewGuid(), UserTwitterID = null, UserInstagramID = null, UserName = "******", UserPassword = passwordImgHandler, UserCode = codeImgHandler, UserPhoneNumber = "0031642775321", UserProfileIMG = null, UserCount = 2 }; Role role = new Role(); role.Name = "Developer"; role.RoleID = Guid.NewGuid(); role.Permissions = new List<Permission>(); Role role2 = new Role(); role2.Name = "Admin"; role2.RoleID = Guid.NewGuid(); role2.Permissions = new List<Permission>(); Role role3 = new Role(); role3.Name = "EndUser"; role3.RoleID = Guid.NewGuid(); role3.Permissions = new List<Permission>(); Role role4 = new Role(); role4.Name = "FestivalAdmin"; role4.RoleID = Guid.NewGuid(); role4.Permissions = new List<Permission>(); Role role5 = new Role(); role5.Name = "ArtistAdmin"; role5.RoleID = Guid.NewGuid(); role5.Permissions = new List<Permission>(); Role role6 = new Role(); role6.Name = "NewsAdmin"; role6.RoleID = Guid.NewGuid(); role6.Permissions = new List<Permission>(); Role role7 = new Role(); role7.Name = "UserAdmin"; role7.RoleID = Guid.NewGuid(); role7.Permissions = new List<Permission>(); Role role8 = new Role(); role8.Name = "Analyzer"; role8.RoleID = Guid.NewGuid(); role8.Permissions = new List<Permission>(); Role role9 = new Role(); role9.Name = "GenreAdmin"; role9.RoleID = Guid.NewGuid(); role9.Permissions = new List<Permission>(); Role role10 = new Role(); role10.Name = "Reporter"; role10.RoleID = Guid.NewGuid(); role10.Permissions = new List<Permission>(); Role role11 = new Role(); role11.Name = "Customer"; role11.RoleID = Guid.NewGuid(); role11.Permissions = new List<Permission>(); Role role12 = new Role(); role12.Name = "Partner"; role12.RoleID = Guid.NewGuid(); role12.Permissions = new List<Permission>(); Role role13 = new Role(); role13.Name = "Journalist"; role13.RoleID = Guid.NewGuid(); role13.Permissions = new List<Permission>(); Role role14 = new Role(); role14.Name = "BannerAdmin"; role14.RoleID = Guid.NewGuid(); role14.Permissions = new List<Permission>(); Role role15 = new Role(); role15.Name = "SponsorAdmin"; role15.RoleID = Guid.NewGuid(); role15.Permissions = new List<Permission>(); Role role16 = new Role(); role16.Name = "AnnouncementAdmin"; role16.RoleID = Guid.NewGuid(); role16.Permissions = new List<Permission>(); Role role17 = new Role(); role17.Name = "RoleAdmin"; role17.RoleID = Guid.NewGuid(); role17.Permissions = new List<Permission>(); Role role18 = new Role(); role18.Name = "Bot"; role18.RoleID = Guid.NewGuid(); role18.Permissions = new List<Permission>(); Permission p = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "ROOT", Weight = 999999999 }; Permission p2 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "IMG_HNDL", Weight = 1000 }; Permission p3 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "END_USER", Weight = 10, }; Permission p4 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "ADMIN", Weight = 1000 }; Permission p5 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "REPORTER", Weight = 1000 }; Permission p6 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "FESTIVAL_ADMIN", Weight = 1000 }; Permission p7 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "ANALYZER", Weight = 1000 }; Permission p8 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "JOURNALIST", Weight = 100 }; Permission p9 = new Permission() { PermissionID = Guid.NewGuid(), PermissionKey = "UPLOADER", Weight = 100 }; //role.Permissions.Add(p); //role2.Permissions.Add(p2); //developer.Roles.Add(role); //FCImageHandler.Roles.Add(role2); Db.P2R.Add(new Permission2Role { P2RID = Guid.NewGuid(), RoleID = role.RoleID, PermissionID = p.PermissionID }); Db.P2R.Add(new Permission2Role { P2RID = Guid.NewGuid(), RoleID = role2.RoleID, PermissionID = p2.PermissionID }); Db.U2R.Add(new User2Role { U2RID = Guid.NewGuid(), RoleID = role.RoleID, UserID = developer.UserID }); Db.U2R.Add(new User2Role { U2RID = Guid.NewGuid(), RoleID = role2.RoleID, UserID = FCImageHandler.UserID }); Db.Permissions.Add(p); Db.Permissions.Add(p2); Db.Permissions.Add(p3); Db.Permissions.Add(p4); Db.Permissions.Add(p5); Db.Permissions.Add(p6); Db.Permissions.Add(p7); Db.Permissions.Add(p8); Db.Permissions.Add(p9); Db.Roles.Add(role); Db.Roles.Add(role2); Db.Roles.Add(role3); Db.Roles.Add(role4); Db.Roles.Add(role5); Db.Roles.Add(role6); Db.Roles.Add(role7); Db.Roles.Add(role8); Db.Roles.Add(role9); Db.Roles.Add(role10); Db.Roles.Add(role11); Db.Roles.Add(role12); Db.Roles.Add(role13); Db.Roles.Add(role14); Db.Roles.Add(role15); Db.Roles.Add(role16); Db.Roles.Add(role17); Db.Roles.Add(role18); Db.ApplicationUsers.Add(developer); Db.ApplicationUsers.Add(FCImageHandler); try { Db.SaveChanges(); SeedFinished(true); } catch(DbEntityValidationException ex) { HandleDbEntityValidationException(ex); } catch(Exception ex) { throw; } } }