如何首先使用MySql和Entity Framework 4.1代码
我正在尝试在 MVCMusicStore 中使用 MySQL 数据库
http://mvcmusicstore.codeplex.com/ 而不是 MSSQL。
我想学习使用 MySQL 进行代码优先开发。
我已将这些代码添加到 web.config
<connectionStrings>
<add name="MusicStoreEntities"
connectionString="Server=localhost; Database=MvcMusicStore; Uid=root; Pwd=;"
providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
<system.data>
<DbProviderFactories>
<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>
</system.data>
MySQL 数据库已创建,但表尚未创建。 我刚刚向我的项目添加了 Mysql.Data.MySQLClient.dll
引用。 我有这样的例外:
为 system.data 创建配置节处理程序时发生错误:
列“InvariantName”被限制为唯一。
值“MySql.Data.MySqlClient”已存在。
(C:\Users\Dauren\Downloads\MvcMusicStore-v3.0\MvcMusicStore-v3.0\MvcMusicStore-Completed\MvcMusicStore\web.config 第 47 行)
I am trying to use MySQL database in MVCMusicStore
http://mvcmusicstore.codeplex.com/ instead of MSSQL.
I would like to learn Code first development with MySQL.
I had added these code to web.config
<connectionStrings>
<add name="MusicStoreEntities"
connectionString="Server=localhost; Database=MvcMusicStore; Uid=root; Pwd=;"
providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
<system.data>
<DbProviderFactories>
<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>
</system.data>
MySQL database is already created but tables are not created.
I have just added Mysql.Data.MySQLClient.dll
reference to my project.
And I have this kind of exception:
An error occurred creating the configuration section handler for system.data:
Column 'InvariantName' is constrained to be unique.
Value 'MySql.Data.MySqlClient' is already present.
(C:\Users\Dauren\Downloads\MvcMusicStore-v3.0\MvcMusicStore-v3.0\MvcMusicStore-Completed\MvcMusicStore\web.config line 47)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个代码:
Try this code: