public static void InitializeContextWithNavigationProperties() { using (DbContextConnectionClass dbContextConnectionClass = new DbContextConnectionClass()) { dbContextConnectionClass.ResetDatabase(); Company companyFirst = null; for (int i = 1; i < 4; i++) { string indexString = i.ToString(); Company company = new Company(); company.CompanyName = indexString; company.Description = indexString; Person person = new Person(); person.PersonName = indexString; person.Description = indexString; company.Person = person; person.Company = company; Office office = new Office(); office.Name = indexString; office.Description = indexString; if (companyFirst == null) { companyFirst = company; } companyFirst.Offices.Add(office); dbContextConnectionClass.Company.Add(company); dbContextConnectionClass.Persons.Add(person); } dbContextConnectionClass.SaveChanges(); } }
public void ClearDatabase() { using (DbContextConnectionClass dbContextConnectionClass = new DbContextConnectionClass()) { dbContextConnectionClass.ResetDatabase(); } }
public void ClearDatabase() { DbContextConnectionClass dbContextConnectionClass = new DbContextConnectionClass().MakeRealDbContext(); dbContextConnectionClass.ResetDatabase(); }