3
I am creating a web application in C# and because of the hosting server, the database is in Mysql. Then I installed Mysql.Data.Entity, EF6, enabled Migrations, added the Migrations class, but when giving the Update-database -Verbose
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 am using Mysql already 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>
The problem is that it is not creating the Tables in the Bank! and when I try to do via Data Model, the SQL connector does not appear, although I have installed it
– Luiz Felipe
Voce used the "add-Migration XX" command? Where XX is a name of your choice to enumerate Migration
– Fernando Medeiros
I did. But he doesn’t create the tables!
– Luiz Felipe
check in your app.config or web.config the database string Connection, may be saving in the default database of the project, go to View>Sql Object Viewer (I don’t remember the name exactly), doing this will open a field on the left of the visual studio, check the databases present there and if any were created
– Fernando Medeiros
Connection String is targeting my Mysql database: localhost:3306. dai on my server, I went to create a Mysql connection, but only appears from SQL Server and Oracle. It does not appear from Mysql, but I installed NET Connector
– Luiz Felipe
Check in the context class constructor of the Entity framework, there is written which connection it is using (inheriting), as when running the update-database it presents no error the table is being created, you just have to figure out where
– Fernando Medeiros
I’m using Context and the Conection string created! I just don’t know where it’s being created then! in the SQL shown in the verbose, it uses dbo.Person, so it’s using Sqlserver? if yes, how could I be directing Mysql in Connectionstring
– Luiz Felipe
Please supplement your question with an excerpt from the context code, thank you
– Fernando Medeiros
I did a test. I added a file, then searched it and it worked! I mean, it’s creating a table!
– Luiz Felipe
Go to View>Server Explorer check all the servers, update the pages, it has to be somewhere there, or it could be in some db local, check the project folders for a file. mdf
– Fernando Medeiros
I believe that changing the XML as I changed the answer will make it work this time, if my answer solves your problem please mark it as the solution, thank you
– Fernando Medeiros