public static void One_Child_TablePerHierarchy_SanityCheck(bool applyColumnType)
        {
            var options = new DbContextOptionsBuilder()
                          .UseSqlServer($"Data Source=(local);Initial Catalog=Test_{nameof(ProgramOneChildTphSanityCheck)}_{applyColumnType};Integrated Security=SSPI;").Options;

            using (var db = new TestContext(options, applyColumnType))
            {
                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();

                // TODO write save logic
                var goodChild = new GoodChild()
                {
                    GoodChildData = Random30Characters()
                };

                db.Add(goodChild);

                var badChild = new BadChild()
                {
                };

                db.Add(badChild);

                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public static void One_TablePerHierarchy_To_One_TablePerHierarchy_Different_Discriminator_Names_With_Identity_Insert()
        {
            var options = new DbContextOptionsBuilder()
                          .UseSqlServer($"Data Source=(local);Initial Catalog=Test_{nameof(ProgramOneTphToOneTphDifferentDiscriminatorNamesWithIdentityInsert)};Integrated Security=SSPI;").Options;

            using (var db = new TestContext(options))
            {
                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();

                // TODO write save logic
                var goodChild = new GoodChild()
                {
                    Parent           = new GoodParent()
                    {
                    }, GoodChildData = Random30Characters()
                };

                db.Add(goodChild);

                var badChild = new BadChild()
                {
                    Parent          = new BadParent()
                    {
                    }, BadChildData = Random30Characters()
                };

                db.Add(badChild);

                var goodParent = new GoodParent()
                {
                    Child = new GoodChild()
                    {
                        GoodChildData = Random30Characters()
                    },
                    GoodParentData = Random30Characters()
                };

                db.Add(goodParent);

                var badParent = new BadParent()
                {
                    Child = new BadChild()
                    {
                        BadChildData = Random30Characters()
                    },
                    BadParentData = Random30Characters()
                };

                db.Add(badParent);

                db.SaveChanges();
            }
        }