Example #1
0
            public override void Seed()
            {
                System.Diagnostics.Debug.Print("Seeding db");

                for (int i = 1; i <= 10; i++)
                {
                    EntityASet.Add(new EntityA {
                        ID = i
                    });
                    EntityBSet.Add(new EntityB {
                        ID = i
                    });
                    EntityCSet.Add(new EntityC {
                        ID = i
                    });
                    EntityLSet.Add(new EntityL {
                        ID = i
                    });
                    EntityDSet.Add(new EntityD {
                        IntValue = i
                    });
                    EntityESet.Add(new EntityE {
                        IntValue = i
                    });
                    EntityFSet.Add(new EntityF {
                        IntValue = i
                    });
                    EntityGSet.Add(new EntityG {
                        StrValue = i.ToString()
                    });
                }

                //  Note: SQL Server does not return records using "in (null)" syntax...
                EntityESet.Add(new EntityE());      //  For a null IntValue record

                EntityHSet.Add(new EntityH {
                    BoolValue = true
                });
                EntityHSet.Add(new EntityH {
                    BoolValue = false
                });

                EntityISet.Add(new EntityI {
                    GuidValue = Guid.Parse("3A298D91-3857-E411-829F-001C428D83FF")
                });
                EntityISet.Add(new EntityI {
                    GuidValue = Guid.Parse("3B298D91-3857-E411-829F-001C428D83FF")
                });
                EntityISet.Add(new EntityI {
                    GuidValue = Guid.NewGuid()
                });
                EntityISet.Add(new EntityI {
                    GuidValue = Guid.NewGuid()
                });

                EntityJSet.Add(new EntityJ {
                    DateValue = new DateTime(2015, 1, 1)
                });
                EntityJSet.Add(new EntityJ {
                    DateValue = new DateTime(2015, 1, 2, 12, 34, 56, 190)
                });
                EntityJSet.Add(new EntityJ {
                    DateValue = new DateTime(2015, 1, 3)
                });
                EntityJSet.Add(new EntityJ {
                    DateValue = DateTime.Now
                });
                EntityJSet.Add(new EntityJ {
                    DateValue = DateTime.Now.AddDays(7)
                });

#if (!SKIP_DATETIMEOFFSET_TEST)
                EntityKSet.Add(new EntityK {
                    DateValue = new DateTime(2015, 1, 1)
                });
                EntityKSet.Add(new EntityK {
                    DateValue = new DateTime(2015, 1, 2, 12, 34, 56, 190)
                });
                EntityKSet.Add(new EntityK {
                    DateValue = new DateTime(2015, 1, 3)
                });
                EntityKSet.Add(new EntityK {
                    DateValue = DateTime.Now
                });
                EntityKSet.Add(new EntityK {
                    DateValue = DateTime.Now.AddDays(7)
                });
#endif

                EntityMSet.Add(new EntityM {
                    ID = 1, EnumValue = TestEnum.Value1
                });
                EntityMSet.Add(new EntityM {
                    ID = 2, EnumValue = TestEnum.Value2
                });
                EntityMSet.Add(new EntityM {
                    ID = 3, EnumValue = TestEnum.Value3
                });
                EntityMSet.Add(new EntityM {
                    ID = 4, EnumValue = TestEnum.Value4
                });
                EntityMSet.Add(new EntityM {
                    ID = 5, EnumValue = TestEnum.Value5
                });

                var tenantID2 = Guid.NewGuid();
                TenantEntityASet.Add(new TenantEntityA
                {
                    ID          = 1,
                    TenantID    = TestContext.TenantID1,
                    EntityBList = new List <TenantEntityB>()
                    {
                        new TenantEntityB {
                            ID = 1, TenantID = TestContext.TenantID1
                        },
                        new TenantEntityB {
                            ID = 2, TenantID = TestContext.TenantID1
                        },
                        new TenantEntityB {
                            ID = 3, TenantID = TestContext.TenantID2
                        },
                        new TenantEntityB {
                            ID = 4, TenantID = tenantID2
                        },
                        new TenantEntityB {
                            ID = 5, TenantID = tenantID2
                        },
                        new TenantEntityB {
                            ID = 6, TenantID = tenantID2
                        }
                    }
                });
                TenantEntityASet.Add(new TenantEntityA
                {
                    ID          = 2,
                    TenantID    = tenantID2,
                    EntityBList = new List <TenantEntityB>()
                    {
                        new TenantEntityB {
                            ID = 10, TenantID = TestContext.TenantID1
                        },
                        new TenantEntityB {
                            ID = 11, TenantID = TestContext.TenantID2
                        },
                        new TenantEntityB {
                            ID = 12, TenantID = TestContext.TenantID2
                        },
                        new TenantEntityB {
                            ID = 13, TenantID = tenantID2
                        },
                        new TenantEntityB {
                            ID = 14, TenantID = tenantID2
                        },
                        new TenantEntityB {
                            ID = 15, TenantID = tenantID2
                        }
                    }
                });

                SaveChanges();
            }
            public override void Seed()
            {
                EntityASet.Add(new EntityA {
                    ID = 1
                });
                EntityASet.Add(new EntityA {
                    ID = 2, DeleteTimestamp = DateTime.Now.AddMinutes(-1)
                });

                EntityBSet.Add(new EntityB {
                    ID = 1
                });
                EntityBSet.Add(new EntityB {
                    ID = 2, DeleteTimestamp = DateTime.Now.AddMinutes(-1)
                });

                EntityCSet.Add(new EntityC {
                    ID = 1
                });
                EntityCSet.Add(new EntityC {
                    ID = 2, DeleteTimestamp = DateTime.Now.AddMinutes(-1)
                });

                EntityDSet.Add(new EntityD {
                    ID = 1
                });
                EntityDSet.Add(new EntityD {
                    ID = 2, DeleteTimestamp = DateTime.Now.AddMinutes(-1)
                });

                EntityESet.Add(new EntityE {
                    ID = 1, TenantID = 1
                });
                EntityESet.Add(new EntityE {
                    ID = 2, TenantID = 2
                });
                EntityESet.Add(new EntityE {
                    ID = 3, TenantID = null
                });

                EntityFSet.Add(new EntityF {
                    ID = 1, TenantID = 1
                });
                EntityFSet.Add(new EntityF {
                    ID = 2, TenantID = 2
                });
                EntityFSet.Add(new EntityF {
                    ID = 3, TenantID = null
                });

                EntityGSet.Add(new EntityG {
                    ID = 1, TenantID = 1
                });
                EntityGSet.Add(new EntityG {
                    ID = 2, TenantID = 2
                });
                EntityGSet.Add(new EntityG {
                    ID = 3, TenantID = null
                });

                EntityHSet.Add(new EntityH {
                    ID = 1, TenantID = 1
                });
                EntityHSet.Add(new EntityH {
                    ID = 2, TenantID = 2
                });
                EntityHSet.Add(new EntityH {
                    ID = 3, TenantID = null
                });

                EntityISet.Add(new EntityI {
                    ID = 1, TenantID = 1
                });
                EntityISet.Add(new EntityI {
                    ID = 2, TenantID = 2
                });
                EntityISet.Add(new EntityI {
                    ID = 3, TenantID = null
                });

                EntityJSet.Add(new EntityJ {
                    ID = 1, Value = 1
                });
                EntityJSet.Add(new EntityJ {
                    ID = 2, Value = 2
                });
                EntityJSet.Add(new EntityJ {
                    ID = 3, Value = 3
                });
                EntityJSet.Add(new EntityJ {
                    ID = 4, Value = 4
                });

                EntityKSet.Add(new EntityK {
                    ID = 1, TenantID = 1, Name = "A"
                });
                EntityKSet.Add(new EntityK {
                    ID = 2, TenantID = 2, Name = "B"
                });
                EntityKSet.Add(new EntityK {
                    ID = 3, TenantID = null, Name = "C"
                });

                EntityLSet.Add(new EntityL {
                    ID = 1, TenantID = 1
                });
                EntityLSet.Add(new EntityL {
                    ID = 2, TenantID = 2
                });
                EntityLSet.Add(new EntityL {
                    ID = 3, TenantID = null
                });

                EntityMSet.Add(new EntityM {
                    ID = 1
                });
                EntityMSet.Add(new EntityM {
                    ID = 2, DeleteTimestamp = DateTime.Now.AddMinutes(-1)
                });

                SaveChanges();
            }