Inheritance: System.Data.Common.DbProviderServices
 public void GetDbProviderManifestTokenDoesNotThrowWhenMissingPersistSecurityInfo()
 {
     using (MySqlConnection connection = new MySqlConnection(GetConnectionString(this.user, this.password, false, true)))
       {
     MySqlProviderServices providerServices = new MySqlProviderServices();
     string token = null;
     connection.Open();
     Assert.DoesNotThrow(delegate() { token = providerServices.GetProviderManifestToken(connection); });
     Assert.IsNotNull(token);
     connection.Close();
       }
 }
        public void GetDbProviderManifestTokenDoesNotThrowWhenLocalized()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");

              using (MySqlConnection connection = new MySqlConnection(GetConnectionString(true)))
              {
            MySqlProviderServices providerServices = new MySqlProviderServices();
            string token = null;

            Assert.DoesNotThrow(delegate() { token = providerServices.GetProviderManifestToken(connection); });
            Assert.IsNotNull(token);
              }
        }
Ejemplo n.º 3
0
    public string GetTableCreateScript(EntitySet entitySet, string connectionString, string version)
    {
      MySqlProviderServices service = new MySqlProviderServices();

      if (!String.IsNullOrEmpty(version))
        service.serverVersion = new Version(version);
      else
      {
        using (var conn = new MySqlConnection(connectionString.Replace(@"""", "")))
        {
          conn.Open();                  
          var v = DBVersion.Parse(conn.ServerVersion.ToString());        
          service.serverVersion = new Version(v.Major + "." + v.Minor);
        }
      }
      if (service.serverVersion == null) service.serverVersion = new Version("5.5");
      return service.GetTableCreateScript(entitySet); 
    }
Ejemplo n.º 4
0
        public string GetTableCreateScript(EntitySet entitySet, string connectionString, string version)
        {
            MySqlProviderServices service = new MySqlProviderServices();

            if (!String.IsNullOrEmpty(version))
            {
                service.serverVersion = new Version(version);
            }
            else
            {
                using (var conn = new MySqlConnection(connectionString.Replace(@"""", "")))
                {
                    conn.Open();
                    var v = DBVersion.Parse(conn.ServerVersion.ToString());
                    service.serverVersion = new Version(v.Major + "." + v.Minor);
                }
            }
            if (service.serverVersion == null)
            {
                service.serverVersion = new Version("5.5");
            }
            return(service.GetTableCreateScript(entitySet));
        }
 static MySqlProviderServices()
 {
     Instance = new MySqlProviderServices();
 }
Ejemplo n.º 6
0
 static MySqlProviderServices()
 {
   Instance = new MySqlProviderServices();
 }
    /// <summary>
    /// Generate and apply sql statemens from the
    /// migration operations list
    /// return false is case of fail or if database doesn't exist
    /// </summary>
    private bool GenerateAndExecuteMySQLStatements(List<MigrationOperation>  migrationOperations)
    {
      MySqlProviderServices ProviderServices;      

      ProviderServices = new MySqlProviderServices();      

      using (BlogContext context = new BlogContext())
      {
        if (!context.Database.Exists()) return false;

        using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
        {
          var migratorGenerator = new MySqlMigrationSqlGenerator();
          var Token = ProviderServices.GetProviderManifestToken(conn);
          var sqlStmts = migratorGenerator.Generate(migrationOperations, providerManifestToken: Token);
          if (conn.State == System.Data.ConnectionState.Closed) conn.Open();
          foreach (MigrationStatement stmt in sqlStmts)
          {
            try
            {
              MySqlCommand cmd = new MySqlCommand(stmt.Sql, conn);
              cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
              return false;
            }            
          }
        }
      }
      return true;
    }