Domanda

I have application developed in Visual Studio 2010, .NET 4.0, using MySql database.

I have installed Entity Framework 5.0 and EF 5.x DbContext Generator for VB (using NuGet), then MySql Connector 6.5.5. I'm using Model First approach, so I created two tables, then I chose "Generate database from model.." option. After setting connection provider and connection parameters (with successful test connection to database), I clicked "Finish", and *.sql file was generated but nothing was created in my database. Worse still, the generated SQL script is in SQL Server Flavour and it has a header:

-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 03/22/2013 12:11:00
-- Generated from EDMX file: C:\Apps\app\DataAccessLayer\DbModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [MyDatabase];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

(...)

How to enforce EF with Mysql and MySql Connector to automatically create database tables, and to generate MySql script, no SQL Server script?

Best regards, WP

È stato utile?

Soluzione

Question comments give us and answer. Summary:

1) Change DDL Generation Template property of the *.edmx model to SSDLToMySQL.tt (VS)

2) Database is not generated automatically. You must execute the generated script yourselves (In Visual Studio in Server Explorer view, or using other tools, i.e PhpMyAdmin).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top