Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
 public void ClearDatabase()
 {
     using (DbContextConnectionClass dbContextConnectionClass = new DbContextConnectionClass()) {
         dbContextConnectionClass.ResetDatabase();
     }
 }
Beispiel #3
0
        public void ClearDatabase()
        {
            DbContextConnectionClass dbContextConnectionClass = new DbContextConnectionClass().MakeRealDbContext();

            dbContextConnectionClass.ResetDatabase();
        }