public void Create(AccountDto account) { if (account == null) { throw new ArgumentNullException($"{nameof(account)} can't be null"); } Console.WriteLine(account.Name); Owner owner = account.ToOwner(); Console.WriteLine($"Owner name: {owner.Name}"); Account addedAccount = account.ToAccount(owner); Console.WriteLine($"In account owner name: {addedAccount.Owner.Name}"); using (var db = new AccountContext()) { db.Owners.Add(owner); db.Accounts.Add(addedAccount); db.SaveChanges(); } }