使用EF4.1 code问题先用MVC3和MySQL [英] Problems using EF4.1 Code First with MVC3 and MySQL

查看:162
本文介绍了使用EF4.1 code问题先用MVC3和MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面这个指南:<一href=\"http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application\" rel=\"nofollow\">http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

所以这是与MVC3 EF code首先,我尝试使用,而不是SQLSERVER MySQL的。

So that is MVC3 with EF Code First and I am trying to use MySQL instead of SQLSERVER.

到目前为止,我已经下载了MySqlConnector /网络(也Devart dotConnect)。
在我的web.config我已经在

So far I have downloaded the MySqlConnector/Net (and also Devart dotConnect). In my web.config I have added the following under

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

接下来,我发现下面还必须添加到web.config。我不知道为什么,虽然。

Next, I found out that the following also has to be added to the web.config. I don't know why though.

<DbProviderFactories>
  <clear/>
  <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>

我有一个所谓的后后一个简单的POCO模型。
我是IM pression下,当这个编译并延迟加载踢,实体框架应该创建一个表对我来说这就是所谓的'后'(或'职位')

I have a simple POCO model for a post called Post. I am under the impression that when this compiles, and the lazy loading kicks in, the entity framework should create a table for me that's called 'post' (or 'posts').

然而,当这个运行时,我得到以下错误:表'project.posts不存在,表示EF不为我创造这个

However, when this runs, I get the following error: "Table 'project.posts' doesn't exist" indicating that the EF does NOT create this for me.

当我使用dotConnect相反,我得到另一个错误:未知数据库DBO

When I use the dotConnect instead, I get the another error: "Unknown database 'dbo'".

有没有人有一些见解,以什么回事?

推荐答案

的MySQL Connector / NET不支持实体框架code首先,直到6.6版。

MySql Connector/NET did not support Entity Framework Code First until version 6.6.

有关MVC的教程与连接器/ NET看到 https://blogs.oracle.com/ MySqlOnWindows /项/ building_an_mvc_3_application

For a tutorial on MVC with Connector/NET see https://blogs.oracle.com/MySqlOnWindows/entry/building_an_mvc_3_application

这篇关于使用EF4.1 code问题先用MVC3和MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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