I have 3 entities that are related (Account Groups to Account Categories to Accounts). I am trying to seed the database. The code below works for seeding Account Group and Account Category but I am unsure how to seed the next level which is account.
var Revenue = new AccountGroup()
{
AccountGroupName = "Revenue",
AccountCategories = new List<AccountCategory>()
{
new AccountCategory { AccountCategoryName = "Base Business Build" },
new AccountCategory { AccountCategoryName = "Contract" },
new AccountCategory { AccountCategoryName = "Other" }
}
};
_context.AccountGroups.Add(Revenue);
_context.AccountCategories.AddRange(Revenue.AccountCategories);
await _context.SaveChangesAsync();
Examples of accounts in the Base Business Build Category would be: Project work, Vertical Sales.
Any help would be greatly appreciated.
Something like :