Ejemplo n.º 1
0
        /// <summary>
        /// 创建一个数据库架构实例
        /// </summary>
        /// <param name="db">数据提供程序实例</param>
        /// <returns></returns>
        public static DbSchema Create(Database db)
        {
            DbSchema schema = null;

            switch (db.DatabaseType)
            {
            case DatabaseType.SqlServer:
                //schema = new SqlServerSchema(db);
                schema = new SqlServerSchema(db);
                break;

            case DatabaseType.Oracle:
                schema = new OracleSchema(db);
                break;

            case DatabaseType.MySql:
                schema = new MySqlSchema(db);
                break;

            case DatabaseType.DB2:
                schema = new DB2Schema(db);
                break;

            case DatabaseType.SQLite:
                schema = new SQLiteSchema(db);
                break;

            default:
                break;
            }

            return(schema);
        }
Ejemplo n.º 2
0
        public void CompareSchema()
        {
            var superSetConnectionString = ConfigurationManager.ConnectionStrings["Persistence"].ConnectionString;
            var subSetConnectionString   = ConfigurationManager.ConnectionStrings["PersistenceEF"].ConnectionString;

            SqlServerSchema.Remove(subSetConnectionString);

            var configuration = new EntityFrameworkDbContextConfiguration <CompareContext>(connectionStringOrName => new CompareContext(connectionStringOrName));

            configuration.ConnectionString(subSetConnectionString);
            configuration.CreateSchema();

            SqlServerSchema.AssertContained(new ConsoleLogger(), superSetConnectionString, subSetConnectionString, false, "__MigrationHistory");
        }
Ejemplo n.º 3
0
        public void CompareSchema()
        {
            var superSetConnectionString = ConfigurationManager.ConnectionStrings["Persistence"].ConnectionString;
            var subSetConnectionString   = ConfigurationManager.ConnectionStrings["PersistenceEF"].ConnectionString;

            SqlServerSchema.Remove(subSetConnectionString);

            var configuration = new EntityFrameworkConfiguration();

            configuration.ConnectionString(subSetConnectionString);
            configuration.ProviderName(EntityFrameworkConfiguration.SqlServerProviderName);
            configuration.RegisterEntitiesFromAssemblyOf <FooConfiguration>();
            configuration.CreateSchema();

            SqlServerSchema.AssertContained(new ConsoleLogger(), superSetConnectionString, subSetConnectionString, false, "EdmMetadata");
        }
Ejemplo n.º 4
0
        private void CompareSchema(string subSetConnectionString, params INHibernateConfigurer[] configurers)
        {
            var superSetConnectionString = ConfigurationManager.ConnectionStrings["Persistence"].ConnectionString;

            SqlServerSchema.Prepare(subSetConnectionString);

            var configuration = new NHibernateConfiguration(new ConsoleLogger {
                DebugLoggingIsEnabled = false
            });

            foreach (var configurer in configurers)
            {
                configuration.RegisterConfigurer(configurer);
            }

            configuration.CreateSchema();

            SqlServerSchema.AssertContained(new ConsoleLogger(), superSetConnectionString, subSetConnectionString, false);
        }
Ejemplo n.º 5
0
        private IEdmModel ModelDB()
        {
            try
            {
                #region odata
                var       optionsBuilder = new DbContextOptionsBuilder <DynamicDbContext>();
                IEdmModel edmModel;
                optionsBuilder = optionsBuilder.UseSqlServer("Server=.;Initial Catalog=test;Trusted_Connection=No;UID=sa;PWD=Your_password123;Connect Timeout=5");

                using (var providerSchema = new SqlServerSchema(optionsBuilder.Options))
                {
                    edmModel = DynamicMiddlewareHelper.CreateEdmModel(providerSchema, informationSchemaMapping: null);
                }
                return(edmModel);

                #endregion
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public List <DataSourceTable> GetTables(string conString)
        {
            SqlServerSchema sqlserverSchema = new SqlServerSchema();

            return(sqlserverSchema.GetTables(conString));
        }
        protected override IInstallerRepository GetRepository(string connectionString)
        {
            var schema = new SqlServerSchema();

            return(new DapperInstallerRepository(GetDbFactory(connectionString), schema));
        }