Code First Migrations MySQL - Specify the '-Verbose' flag to view the SQL statements being applied to the target database

3

I'm creating a Web application in C # and for the sake of the hosting server, the database is in MySql. So I installed MySql.Data.Entity, EF6, I activated Migrations, added the class Migrations, but at the time of giving Update-database -Verbose it returns the message:

  

Specify the '-Verbose' flag to view the SQL statements being applied to the target database.

As I already have EasyPHP installed, I'm using MySql that already comes in it!

Context:

public DBContexto() : base("Contexto") { }
    public DbSet<Pessoa> Pessoas { get; set; }
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove();
        modelBuilder.Conventions.Remove();
    }

Conection String: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <connectionStrings> <add name="Contexto" connectionString="Data Source=127.0.0.1:3306;Database=dbyou;Id=root;Password=;" providerName="MySql.Data.MySqlClient" /> </connectionStrings> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="v11.0" /> </parameters> </defaultConnectionFactory> </entityFramework> </configuration>

    
asked by anonymous 03.07.2015 / 07:42

1 answer

3

This is a standard message stating that when adding the Verbose flag you will see which SQL queries are being executed in the applied migration, if you received only this message you can rest easy, it does not mean that some error has occurred.

Add note above context class :

 [DbConfigurationType(typeof(MySqlEFConfiguration))]
 public class SeuContexto{

    public SeuContexto()
        : base(/*AQUI DEVE ESTAR O NOME DA CONEXÃO DO CONNECTION STRING*/)
    {        
    }

Make sure your web.config or app.config has your MySQL connection string, if you do not add it and refer to it in the context context.

It may be that the reason for not saving is here:

    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="v11.0" />
  </parameters>
</defaultConnectionFactory>

Because it is using the LocalDB connectionFactory, change to :

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
  <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, 
    MySql.Data.Entity.EF6" />
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, 
    EntityFramework.SqlServer" />
</providers>

Here is a link to a problem similar to yours: link

    
03.07.2015 / 13:54