Problems using EF4.1 Code First with MVC3 and MySQL
I am following this guide: http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
So that is MVC3 with EF Code First and I am trying to use MySQL instead of SQLSERVER.
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"/>
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>
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 shou开发者_运维问答ld create a table for me that's called 'post' (or 'posts').
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.
When I use the dotConnect instead, I get the another error: "Unknown database 'dbo'".
Does anyone have some insight as to what's going on?
We have already replied to you at our forum here.
Feel free to contact us if you encounter any other problems with our components.
MySql Connector/NET did not support Entity Framework Code First until version 6.6.
For a tutorial on MVC with Connector/NET see https://blogs.oracle.com/MySqlOnWindows/entry/building_an_mvc_3_application
精彩评论