为MySQL连接字符串,VS2010临,ASP .NET MVC3 [英] Connection String for MySQL, VS2010 Pro, ASP .NET MVC3

查看:322
本文介绍了为MySQL连接字符串,VS2010临,ASP .NET MVC3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我在下面的本教程,而是使用SQL精简,我想使用MySQL。我在遇到需要此连接的连接字符串的麻烦。

I'm following this tutorial, but instead of using SQL Compact, I'd like to use MySQL. I'm having trouble with the connection string needed for this connection.

我已经安装了MySQL连接器v6.4.4。

I've installed MySQL Connector v6.4.4.

我现在正试图组成的连接字符串。

I'm now trying to compose the connection string.

如果我坚持

我试图创建通过右键单击控制器一个控制器>添加控制器。我选择电影模式和MovieDBContext语境。我收到一个错误说无法检索元数据。

I'm trying to create a Controller by right-clicking Controllers > Add Controller. I select the Movie Model and the MovieDBContext Context. I receive an error saying "Unable to retrieve metadata".

连接字符串尝试


  1. 我试过基本的连接字符串中希望,实体将自动尝试使用MySQL连接器:

  1. I've tried the basic connection string in hopes that Entity would automatically try to use the MySQL connector:

Server=localhost;Database=MovieDB;Uid=root;Pwd=pass;


  • 我试过方法中使用这里,我得到另一个无法检索元数据的错误。

  • I've tried the method used here, and I get another "Unable to retrieve metadata" error.

    有没有什么办法让MySQL的这项工作?

    Is there any way to make this work with MySQL?

    推荐答案

    重要的部分是:MySql.Data.MySqlClient

    The important part is: MySql.Data.MySqlClient

    <add name="MovieDBContext"
             connectionString="Server=localhost;Database=MovieDB;Uid=root;Pwd=pass;"
             providerName="MySql.Data.MySqlClient"/>
    

    我知道......问题是老了,但我绊倒了这个藏汉,所以这里的答案。

    I know... the question is old, but I tripped over this aswell, so here the answer.

    这篇关于为MySQL连接字符串,VS2010临,ASP .NET MVC3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆