ASP.NET MVC使用MySQL数据库

1.新建MVC Web项目;
2.打开管理Nuget程序包 搜索:MySql.Data && MySql.Data.Entity 点击安装
3.修改连接字符串(默认是SqlServer)

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Gary.Web-20170523110735.mdf;Initial Catalog=aspnet-Gary.Web-20170523110735;Integrated Security=True" providerName="System.Data.SqlClient" />
    <!--<add name="GaryDBContext" connectionString="Data Source=127.0.0.1;Initial Catalog=GaryWeb;Integrated Security=True;User Id=sa;Password=123456"
         providerName="System.Data.SqlClient" />-->
    <add name="GaryDBContext" connectionString="Data Source=127.0.0.1;Database=GaryWeb;User Id=root;Password=123456;charset=utf8;port=3306"
         providerName="MySql.Data.MySqlClient" />

4.修改providers

<providers>
      <!--<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />-->
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
    </providers>
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Gary_888/article/details/72831950
个人分类: ASP.NET MVC
上一篇Oracle 性能优化
下一篇C#连接SQLServer数据库
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭