首页 新闻 会员 周边

Entity Framwork 4.1 问题?

0
悬赏园豆:20 [待解决问题]

Entity Framwork 4.1 怎么连接mysql数据库,并且可以自动创建数据库和表

雪松--努力的主页 雪松--努力 | 初学一级 | 园豆:76
提问于:2011-09-15 10:21
< >
分享
所有回答(3)
0

在配置文件中添加:

<add name="name"
connectionString
="Server=localhost; Database=dbname; Uid=root; Pwd=;"
providerName
="MySql.Data.MySqlClient"/>
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"/>
<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.Data.MySQLClient.dll了

artwl | 园豆:16736 (专家六级) | 2011-09-15 10:32
0

 在 System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.InvalidOperationException: The model backing the 'DBtest' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

出现这个错误

雪松--努力 | 园豆:76 (初学一级) | 2011-09-16 10:01
0

可能有时候要更改一些配置

喬喬AI | 园豆:996 (小虾三级) | 2011-09-19 23:51

那需要改哪里设置啊

支持(0) 反对(0) 雪松--努力 | 园豆:76 (初学一级) | 2011-09-20 08:41

@雪松--努力:这个我就说不清楚了,我刚接触数据库没多久,网上搜一下看看,根据错误信息

支持(0) 反对(0) 喬喬AI | 园豆:996 (小虾三级) | 2011-09-20 12:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册