public void GetIScaffoldingModelFactory()
        {
            //SETUP
            var serviceProvider = new SqlServerDesignTimeServices().GetDesignTimeProvider();

            //ATTEMPT
            var factory = serviceProvider.GetService <IScaffoldingModelFactory>();

            //VERIFY
            factory.ShouldNotBeNull();
            factory.ShouldBeType <RelationalScaffoldingModelFactory>();
        }
예제 #2
0
        public void GetDatabaseModel()
        {
            //SETUP
            var serviceProvider = new SqlServerDesignTimeServices().GetDesignTimeProvider();
            var factory         = serviceProvider.GetService <IDatabaseModelFactory>();

            //ATTEMPT
            var model = factory.Create(_connectionString, new string[] { }, new string[] { });

            //VERIFY
            model.ShouldNotBeNull();
        }
예제 #3
0
        public Stage1ComparerMyEntityDiff(ITestOutputHelper output)
        {
            _output  = output;
            _options = this
                       .CreateUniqueClassOptions <MyEntityDbContext>();
            var serviceProvider = new SqlServerDesignTimeServices().GetDesignTimeProvider();
            var factory         = serviceProvider.GetService <IDatabaseModelFactory>();

            using (var context = new MyEntityDbContext(_options))
            {
                _connectionString = context.Database.GetDbConnection().ConnectionString;
                context.Database.EnsureCreated();
                _databaseModel = factory.Create(_connectionString, new string[] { }, new string[] { });
            }
        }
예제 #4
0
        public Stage1ComparerMyEntityDiff(ITestOutputHelper output)
        {
            _output = output;

            var serviceProvider = new SqlServerDesignTimeServices().GetDesignTimeProvider();
            var factory         = serviceProvider.GetService <IDatabaseModelFactory>();

            var options = this.CreateUniqueClassOptions <MyEntityDbContext>(
                builder => builder.ReplaceService <IModelCacheKeyFactory, MyEntityModelCacheKeyFactory>());

            using (var context = new MyEntityDbContext(options, MyEntityDbContext.Configs.NormalTable))
            {
                context.Database.EnsureClean();
                var connectionString = context.Database.GetDbConnection().ConnectionString;
                databaseModel = factory.Create(connectionString,
                                               new DatabaseModelFactoryOptions(new string[] { }, new string[] { }));
            }
        }
예제 #5
0
        public Stage2ComparerMyEntityDiff(ITestOutputHelper output)
        {
            _output = output;
            var options = this
                          .CreateUniqueClassOptions <MyEntityDbContext>();
            var serviceProvider = new SqlServerDesignTimeServices().GetDesignTimeProvider();
            var factory         = serviceProvider.GetService <IDatabaseModelFactory>();

            using (var context = new MyEntityDbContext(options))
            {
                var connectionString = context.Database.GetDbConnection().ConnectionString;
                context.Database.EnsureCreated();
#if NETCOREAPP2_1
                _databaseModel = factory.Create(connectionString, new string[] { }, new string[] { });
#elif NETCOREAPP3_0
                _databaseModel = factory.Create(connectionString,
                                                new DatabaseModelFactoryOptions(new string[] { }, new string[] { }));
#endif
            }
        }
        public void GetBookContextDatabaseModel()
        {
            //SETUP
            var options = this.CreateUniqueClassOptions <BookContext>();

            using var context = new BookContext(options);
            context.Database.EnsureClean();

            var serviceProvider = new SqlServerDesignTimeServices().GetDesignTimeProvider();
            var factory         = serviceProvider.GetService <IDatabaseModelFactory>();

            //ATTEMPT
            var model = factory.Create(context.Database.GetConnectionString(),
                                       new DatabaseModelFactoryOptions(new string[] { }, new string[] { }));

            //VERIFY
            model.ShouldNotBeNull();
            model.Tables.Select(x => x.Name).OrderBy(x => x).ToArray()
            .ShouldEqual(new [] { "Authors", "BookAuthor", "Books", "BookTag", "PriceOffers", "Review", "Tags" });
            model.DefaultSchema.ShouldEqual("dbo");
        }
        public void GetBookContextDatabaseModelWithView()
        {
            //SETUP
            var options = this.CreateUniqueClassOptions <BookContext>();

            using var context = new BookContext(options);
            context.Database.EnsureClean();
            var filepath = TestData.GetFilePath("AddViewToBookContext.sql");

            context.ExecuteScriptFileInTransaction(filepath);

            var serviceProvider = new SqlServerDesignTimeServices().GetDesignTimeProvider();
            var factory         = serviceProvider.GetService <IDatabaseModelFactory>();

            //ATTEMPT
            var model = factory.Create(context.Database.GetConnectionString(),
                                       new DatabaseModelFactoryOptions(new string[] { }, new string[] { }));

            //VERIFY
            model.ShouldNotBeNull();
            model.Tables.Select(x => x.Name).OrderBy(x => x).ToArray()
            .ShouldEqual(new[] { "Authors", "BookAuthor", "Books", "BookTag", "MyView", "PriceOffers", "Review", "Tags" });
        }