public static void AddTestEmployeesToDb(this Chapter06Context context)
        {
            var ceo = new Employee("CEO", Roles.Management, null);
            //development
            var cto   = new Employee("CTO", Roles.Management | Roles.Development, ceo);
            var pm1   = new Employee("ProjectManager1", Roles.Management | Roles.Development, cto);
            var dev1a = new Employee("dev1a", Roles.Development, pm1);
            var dev1b = new Employee("dev1b", Roles.Development, pm1);
            var pm2   = new Employee("ProjectManager2", Roles.Management | Roles.Development, cto);
            var dev2a = new Employee("dev2a", Roles.Development, pm2);
            var dev2b = new Employee("dev2b", Roles.Development, pm2);
            //sales
            var salesDir = new Employee("SalesDir", Roles.Management | Roles.Sales, ceo);
            var sales1   = new Employee("sales1", Roles.Sales, salesDir);
            var sales2   = new Employee("sales2", Roles.Sales, salesDir);

            context.AddRange(ceo, cto, pm1, pm2, dev1a, dev1b, dev2a, dev2b, salesDir, sales1, sales2);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static ManyTop AddManyTopWithRelationsToDb(this Chapter06Context context, int numRelations = 100)
        {
            var manyTop = new ManyTop();

            manyTop.Collection1 = new Collection <Many1>();
            manyTop.Collection2 = new Collection <Many2>();
            manyTop.Collection3 = new Collection <Many3>();
            for (int i = 0; i < numRelations; i++)
            {
                manyTop.Collection1.Add(new Many1());
                manyTop.Collection2.Add(new Many2());
                manyTop.Collection3.Add(new Many3());
            }

            context.Add(manyTop);
            context.SaveChanges();

            return(manyTop);
        }