时间:2021-07-01 10:21:17 帮助过:3人阅读
<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.9.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> </DbProviderFactories>
然后我们需要自己增加连接字符串
<connectionStrings> <add name="MyContext" connectionString="Data Source=localhost;port=3306;Initial Catalog=Test;user id=root;password=1111;" providerName="MySql.Data.MySqlClient"/> </connectionStrings>
配置好之后,可以写代码了
[DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))] public class MyContext : DbContext { public MyContext() : base("name=MyContext") { public DbSet<Data> Datas { get; set; } 这里是各个model } }
接下来就是开始按业务需求写代码了,期待吧,准确地说,是期待接下来的各种坑,我已经做好了心理准备。
EntityFramework+MySql 笔记1
标签: