public void AddColumnOperationMigration()
        {
            var migrationOperations = new List <MigrationOperation>();

            if (ProviderManifest == null)
            {
                ProviderManifest = new MySqlProviderManifest(st.Version.ToString());
            }

            TypeUsage tu     = TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32));
            TypeUsage result = ProviderManifest.GetStoreType(tu);

            var intColumn = new ColumnModel(PrimitiveTypeKind.Int32, result)
            {
                Name       = "TotalPosts",
                IsNullable = false
            };

            var addColumnMigratioOperation = new AddColumnOperation("Blogs", intColumn);

            migrationOperations.Add(addColumnMigratioOperation);

            using (BlogContext context = new BlogContext())
            {
                if (context.Database.Exists())
                {
                    context.Database.Delete();
                }
                context.Database.Create();

                using (MySqlConnection conn = new MySqlConnection(context.Database.Connection.ConnectionString))
                {
                    if (conn.State == System.Data.ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    Assert.Equal(true, GenerateAndExecuteMySQLStatements(migrationOperations));

                    MySqlCommand    query  = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type from information_schema.Columns where table_schema ='" + conn.Database + "' and table_name = 'Blogs' and column_name ='TotalPosts'", conn);
                    MySqlDataReader reader = query.ExecuteReader();
                    while (reader.Read())
                    {
                        Assert.Equal("TotalPosts", reader[0].ToString());
                        Assert.Equal("NO", reader[1].ToString());
                        Assert.Equal("int", reader[2].ToString());
                    }
                    reader.Close();
                    conn.Close();
                }
            }
        }
 public void CanMapByteTypeToUTinyInt()
 {
     using (MySqlConnection connection = new MySqlConnection(st.ConnectionString))
     {
         MySqlProviderManifest pm = new MySqlProviderManifest(st.Version.ToString());
         TypeUsage             tu = TypeUsage.CreateDefaultTypeUsage(
             PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Byte));
         TypeUsage result = pm.GetStoreType(tu);
         Assert.Equal("utinyint", result.EdmType.Name);
     }
 }
        public void TestingMaxLengthWithFixedLenghtTrueFacets()
        {
            using (MySqlConnection connection = new MySqlConnection(st.ConnectionString))
            {
                MySqlProviderManifest pm = new MySqlProviderManifest(st.Version.ToString());
                TypeUsage             tu = TypeUsage.CreateStringTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, true);
                TypeUsage result = pm.GetStoreType(tu);
                Assert.Equal("char", result.EdmType.Name);

                tu = TypeUsage.CreateStringTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, true, Int32.MaxValue);
                result = pm.GetStoreType(tu);
                Assert.Equal("char", result.EdmType.Name);

                tu = TypeUsage.CreateStringTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, true, 70000);
                result = pm.GetStoreType(tu);
                Assert.Equal("char", result.EdmType.Name);
            }
        }
        public void TestingMaxLengthFacet()
        {
            using (MySqlConnection connection = new MySqlConnection(st.GetConnectionString(true)))
            {
                MySqlProviderManifest pm = new MySqlProviderManifest(st.Version.ToString());
                TypeUsage             tu = TypeUsage.CreateStringTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, false);
                TypeUsage result = pm.GetStoreType(tu);
                Assert.Equal("longtext", result.EdmType.Name);

                tu = TypeUsage.CreateStringTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, false, Int32.MaxValue);
                result = pm.GetStoreType(tu);
                Assert.Equal("longtext", result.EdmType.Name);

                tu = TypeUsage.CreateStringTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String), false, false, 70000);
                result = pm.GetStoreType(tu);
                Assert.Equal("mediumtext", result.EdmType.Name);
            }
        }