Skip to content

Commit a5255fb

Browse files
committed
lock seeding data in ef migration
1 parent 221a339 commit a5255fb

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

src/Modules/SimplCommerce.Module.Catalog/Data/CatalogCustomModelBuilder.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Microsoft.EntityFrameworkCore;
2-
using Microsoft.EntityFrameworkCore.Metadata;
1+
using System;
2+
using Microsoft.EntityFrameworkCore;
33
using SimplCommerce.Infrastructure.Data;
44
using SimplCommerce.Module.Catalog.Models;
55
using SimplCommerce.Module.Core.Models;
@@ -38,24 +38,24 @@ public void Build(ModelBuilder modelBuilder)
3838
modelBuilder.Entity<AppSetting>().HasData(
3939
new AppSetting("Catalog.ProductPageSize") { Module = "Catalog", IsVisibleInCommonSettingPage = true, Value = "10" },
4040
new AppSetting("Catalog.IsProductPriceIncludeTax") { Module = "Catalog", IsVisibleInCommonSettingPage = true, Value = "true" }
41-
);
41+
);
4242

4343
modelBuilder.Entity<EntityType>().HasData(
4444
new EntityType("Category") { RoutingController = "Category", RoutingAction = "CategoryDetail", IsMenuable = true },
4545
new EntityType("Brand") { RoutingController = "Brand", RoutingAction = "BrandDetail", IsMenuable = true },
4646
new EntityType("Product") { RoutingController = "Product", RoutingAction = "ProductDetail", IsMenuable = false }
47-
);
47+
);
4848

4949
modelBuilder.Entity<ProductOption>().HasData(
5050
new ProductOption(1) { Name = "Color" },
5151
new ProductOption(2) { Name = "Size" }
52-
);
52+
);
5353

5454
modelBuilder.Entity<Widget>().HasData(
55-
new Widget("CategoryWidget") { Name = "Category Widget", ViewComponentName = "CategoryWidget", CreateUrl = "widget-category-create", EditUrl = "widget-category-edit" },
56-
new Widget("ProductWidget") { Name = "Product Widget", ViewComponentName = "ProductWidget", CreateUrl = "widget-product-create", EditUrl = "widget-product-edit" },
57-
new Widget("SimpleProductWidget") { Name = "Simple Product Widget", ViewComponentName = "SimpleProductWidget", CreateUrl = "widget-simple-product-create", EditUrl = "widget-simple-product-edit" }
58-
);
55+
new Widget("CategoryWidget") { Name = "Category Widget", ViewComponentName = "CategoryWidget", CreateUrl = "widget-category-create", EditUrl = "widget-category-edit", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 160, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)) },
56+
new Widget("ProductWidget") { Name = "Product Widget", ViewComponentName = "ProductWidget", CreateUrl = "widget-product-create", EditUrl = "widget-product-edit", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 163, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)) },
57+
new Widget("SimpleProductWidget") { Name = "Simple Product Widget", ViewComponentName = "SimpleProductWidget", CreateUrl = "widget-simple-product-create", EditUrl = "widget-simple-product-edit", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 163, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)) }
58+
);
5959
}
6060
}
6161
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.EntityFrameworkCore;
1+
using System;
2+
using Microsoft.EntityFrameworkCore;
23
using SimplCommerce.Infrastructure.Data;
34
using SimplCommerce.Module.Cms.Models;
45
using SimplCommerce.Module.Core.Models;
@@ -12,17 +13,17 @@ public void Build(ModelBuilder modelBuilder)
1213
modelBuilder.Entity<Menu>().HasData(
1314
new Menu(1) { Name = "Customer Services", IsPublished = true, IsSystem = true },
1415
new Menu(2) { Name = "Information", IsPublished = true, IsSystem = true }
15-
);
16+
);
1617

1718
modelBuilder.Entity<EntityType>().HasData(
1819
new EntityType("Page") { RoutingController = "Page", RoutingAction = "PageDetail", IsMenuable = true }
19-
);
20+
);
2021

2122
modelBuilder.Entity<Widget>().HasData(
22-
new Widget("HtmlWidget") { Name = "Html Widget", ViewComponentName = "HtmlWidget", CreateUrl = "widget-html-create", EditUrl = "widget-html-edit" },
23-
new Widget("CarouselWidget") { Name = "Carousel Widget", ViewComponentName = "CarouselWidget", CreateUrl = "widget-carousel-create", EditUrl = "widget-carousel-edit" },
24-
new Widget("SpaceBarWidget") { Name = "SpaceBar Widget", ViewComponentName = "SpaceBarWidget", CreateUrl = "widget-spacebar-create", EditUrl = "widget-spacebar-edit" }
25-
);
23+
new Widget("HtmlWidget") { Name = "Html Widget", ViewComponentName = "HtmlWidget", CreateUrl = "widget-html-create", EditUrl = "widget-html-edit", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 164, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)) },
24+
new Widget("CarouselWidget") { Name = "Carousel Widget", ViewComponentName = "CarouselWidget", CreateUrl = "widget-carousel-create", EditUrl = "widget-carousel-edit", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 164, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)) },
25+
new Widget("SpaceBarWidget") { Name = "SpaceBar Widget", ViewComponentName = "SpaceBarWidget", CreateUrl = "widget-spacebar-create", EditUrl = "widget-spacebar-edit", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 164, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)) }
26+
);
2627
}
2728
}
2829
}

src/Modules/SimplCommerce.Module.Core/Data/CoreSeedData.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ public static void SeedData(ModelBuilder builder)
1111
builder.Entity<AppSetting>().HasData(
1212
new AppSetting("Global.AssetVersion") { Module = "Core", IsVisibleInCommonSettingPage = true, Value = "1.0" },
1313
new AppSetting("Theme") { Module = "Core", IsVisibleInCommonSettingPage = true, Value = "Generic" }
14-
);
14+
);
1515

1616
builder.Entity<EntityType>().HasData(
1717
new EntityType("Vendor") { RoutingController = "Vendor", RoutingAction = "VendorDetail", IsMenuable = false }
18-
);
18+
);
1919

2020
builder.Entity<Role>().HasData(
21-
new Role { Id = 1, Name = "admin", NormalizedName = "ADMIN" },
22-
new Role { Id = 2, Name = "customer", NormalizedName = "CUSTOMER" },
23-
new Role { Id = 3, Name = "guest", NormalizedName = "GUEST" },
24-
new Role { Id = 4, Name = "vendor", NormalizedName = "VENDOR" }
25-
);
21+
new Role { Id = 1L, ConcurrencyStamp = "4776a1b2-dbe4-4056-82ec-8bed211d1454", Name = "admin", NormalizedName = "ADMIN" },
22+
new Role { Id = 2L, ConcurrencyStamp = "00d172be-03a0-4856-8b12-26d63fcf4374", Name = "customer", NormalizedName = "CUSTOMER" },
23+
new Role { Id = 3L, ConcurrencyStamp = "d4754388-8355-4018-b728-218018836817", Name = "guest", NormalizedName = "GUEST" },
24+
new Role { Id = 4L, ConcurrencyStamp = "71f10604-8c4d-4a7d-ac4a-ffefb11cefeb", Name = "vendor", NormalizedName = "VENDOR" }
25+
);
2626

2727
builder.Entity<User>().HasData(
28-
new User { IsDeleted = true, Id = 2, UserGuid = Guid.NewGuid(), FullName = "System User", UserName = "[email protected]", NormalizedUserName = "[email protected]", Email = "[email protected]", NormalizedEmail = "[email protected]", PasswordHash = "AQAAAAEAACcQAAAAEAEqSCV8Bpg69irmeg8N86U503jGEAYf75fBuzvL00/mr/FGEsiUqfR0rWBbBUwqtw==", SecurityStamp = Guid.NewGuid().ToString() },
29-
new User { Id = 10, UserGuid = Guid.NewGuid(), FullName = "Shop Admin", UserName = "[email protected]", NormalizedUserName = "[email protected]", Email = "[email protected]", NormalizedEmail = "[email protected]", PasswordHash = "AQAAAAEAACcQAAAAEAEqSCV8Bpg69irmeg8N86U503jGEAYf75fBuzvL00/mr/FGEsiUqfR0rWBbBUwqtw==", SecurityStamp = Guid.NewGuid().ToString() }
30-
);
28+
new User { Id = 2L, AccessFailedCount = 0, ConcurrencyStamp = "101cd6ae-a8ef-4a37-97fd-04ac2dd630e4", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 189, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)), Email = "[email protected]", EmailConfirmed = false, FullName = "System User", IsDeleted = true, LockoutEnabled = false, NormalizedEmail = "[email protected]", NormalizedUserName = "[email protected]", PasswordHash = "AQAAAAEAACcQAAAAEAEqSCV8Bpg69irmeg8N86U503jGEAYf75fBuzvL00/mr/FGEsiUqfR0rWBbBUwqtw==", PhoneNumberConfirmed = false, SecurityStamp = "a9565acb-cee6-425f-9833-419a793f5fba", TwoFactorEnabled = false, UpdatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 189, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)), UserGuid = new Guid("5f72f83b-7436-4221-869c-1b69b2e23aae"), UserName = "[email protected]" },
29+
new User { Id = 10L, AccessFailedCount = 0, ConcurrencyStamp = "c83afcbc-312c-4589-bad7-8686bd4754c0", CreatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 190, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)), Email = "[email protected]", EmailConfirmed = false, FullName = "Shop Admin", IsDeleted = false, LockoutEnabled = false, NormalizedEmail = "[email protected]", NormalizedUserName = "[email protected]", PasswordHash = "AQAAAAEAACcQAAAAEAEqSCV8Bpg69irmeg8N86U503jGEAYf75fBuzvL00/mr/FGEsiUqfR0rWBbBUwqtw==", PhoneNumberConfirmed = false, SecurityStamp = "d6847450-47f0-4c7a-9fed-0c66234bf61f", TwoFactorEnabled = false, UpdatedOn = new DateTimeOffset(new DateTime(2018, 5, 29, 4, 33, 39, 190, DateTimeKind.Unspecified), new TimeSpan(0, 7, 0, 0, 0)), UserGuid = new Guid("ed8210c3-24b0-4823-a744-80078cf12eb4"), UserName = "[email protected]" }
30+
);
3131

3232
builder.Entity<UserRole>().HasData(
3333
new UserRole { UserId = 10, RoleId = 1 }
34-
);
34+
);
3535

3636
builder.Entity<WidgetZone>().HasData(
3737
new WidgetZone(1) { Name = "Home Featured" },
3838
new WidgetZone(2) { Name = "Home Main Content" },
3939
new WidgetZone(3) { Name = "Home After Main Content" }
40-
);
40+
);
4141

4242
builder.Entity<Country>().HasData(
4343
new Country("VN") { Code3 = "VNM", Name = "Việt Nam", IsBillingEnabled = true, IsShippingEnabled = true, IsCityEnabled = false, IsZipCodeEnabled = false, IsDistrictEnabled = true },

0 commit comments

Comments
 (0)