public static void Initialize(Database1Context context)
        {
            context.Database.EnsureCreated();

            // Look for any persons.
            if (context.Person.Any())
            {
                return;   // DB has been seeded
            }

            var persons = new Person[]
            {
                new Person {
                    FirstName = "Carson", LastName = "Alexander"
                },
                new Person {
                    FirstName = "Meredith", LastName = "Alonso"
                },
                new Person {
                    FirstName = "Arturo", LastName = "Anand"
                },
                new Person {
                    FirstName = "Gytis", LastName = "Barzdukas"
                },
                new Person {
                    FirstName = "Yan", LastName = "Li"
                },
            };

            foreach (Person s in persons)
            {
                context.Person.Add(s);
            }
            context.SaveChanges();
        }
        public static void Initialize(Database1Context database1Db, Database2Context context)
        {
            context.Database.EnsureCreated();

            // Look for any department assignments.
            if (context.DepartmentAssignments.Any())
            {
                return;   // DB has been seeded
            }
            // Look for persons available to seed
            if (!database1Db.Person.Any())
            {
                return;
            }

            var dps = new List <DepartmentAssignment>();

            foreach (Person p in database1Db.Person)
            {
                dps.Add(new DepartmentAssignment {
                    PersonID = p.ID, DepartmentName = "IT"
                });
            }

            foreach (DepartmentAssignment s in dps)
            {
                context.DepartmentAssignments.Add(s);
            }

            context.SaveChanges();
        }
示例#3
0
 public IndexModel(ElasticDatabaseTransactions.Data.Database1Context context)
 {
     _context = context;
 }
示例#4
0
 public DetailsModel(ElasticDatabaseTransactions.Data.Database1Context context1, ElasticDatabaseTransactions.Data.Database2Context context2)
 {
     _context1 = context1;
     _context2 = context2;
 }