Skip to content

Commit dcfc0f7

Browse files
committed
Fixed partTypes not being seeded correctly on new databases. It would get patched on the second run, but that's no good.
1 parent bee0239 commit dcfc0f7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Binner/Data/Binner.Data/BinnerContextInitializer.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ public static void Initialize(BinnerContext context, Func<string, string> passwo
2626
{
2727
// seed data
2828
SeedInitialUsers(context, passwordHasher);
29+
if (context.ChangeTracker.HasChanges())
30+
{
31+
context.SaveChanges();
32+
}
2933
SeedSystemPartTypes(context);
3034
if (context.ChangeTracker.HasChanges())
3135
{
3236
context.SaveChanges();
33-
transaction.Commit();
3437
}
38+
transaction.Commit();
3539
}
3640
catch(Exception)
3741
{
@@ -74,6 +78,8 @@ private static void SeedSystemPartTypes(BinnerContext context)
7478
Name = partType.Value,
7579
ParentPartTypeId = parentPartTypeId,
7680
DateCreatedUtc = DateTime.UtcNow,
81+
OrganizationId = 1,
82+
UserId = 1
7783
};
7884
context.PartTypes.Add(record);
7985
}

0 commit comments

Comments
 (0)