ABP框架系列之二十三:(EF-MySql-Integration-EF-MySql-集成)
Introduction
While our default templates designed to work with SQL Server, you can easily modify them to work with MySql. In order to do that, you need to follow below steps.
Download Project
Go to http://aspnetboilerplate.com/Templates and download a new project. Select ASP.NET MVC 5.x tab and don't forget to select Entity Framework.
Install MySql.Data.Entity
Then you need to install MySql.Data.Entity nuget package to your .EntityFramework and .Web projects. Installing this nuget package to your .Web project should make necessary changes in your web.config file.
Open your DbContext's configuration class (Configuration.cs) and place below code in it's constructor
SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator());
Configure ConnectionString
You need to change your connection string in the web.config file in order to work with your MySql database. An example connection string would be
<add name="Default" connectionString="server=localhost;port=3306;database=sampledb;uid=root;password=***" providerName="MySql.Data.MySqlClient"/>
Re-generate migrations(重新生成迁移)
If you choose "Include module zero?" while downloading your startup template, there will be some migration files included in your project but those files are generated for Sql Server. Delete all migration files in your.EntityFramework project under Migrations folder. Migration files start with a timestamp. A migration file name would be like this "201506210746108_AbpZero_Initial"
After deleting all migration files, select your .Web project as startup project, open Visual Studio's Package Manager Console and select .EntityFramework project as default project in Package Manager Console. Then run below command to add migration for MySql.
如果您选择“包括模块零?”在下载启动模板时,将在项目中包含一些迁移文件,但这些文件是为SQL Server生成的。删除所有迁移文件your.entityframework项目文件夹下的迁徙。迁移文件以一个时间戳开始。迁移文件名会是这样的“201506210746108_abpzero_initial”
删除所有迁移文件,之后选择你。Web项目为启动项目,打开Visual Studio的软件包管理器控制台和选择。EntityFramework项目作为软件包管理器控制台的默认项目。然后运行下面的命令为mysql添加迁移。
Add-Migration "AbpZero_Initial"
Now you can create your database using below command
Update-Database
It is all done, now you can run your project with MySql.
ABP框架系列之二十三:(EF-MySql-Integration-EF-MySql-集成)的更多相关文章
- ABP框架系列之二:(Entity Framework Core-实体核心框架)
Introduction(介绍) Abp.EntityFrameworkCore nuget package is used to integrate to Entity Framework (EF) ...
- ABP框架系列之二十:(Dependency-Injection-依赖注入)
What is Dependency Injection If you already know Dependency Injection concept, Constructor and Prope ...
- ABP框架系列之二十七:(Feature-Management-特征管理)
Introduction Most SaaS (multi-tenant) applications have editions (packages) those have different fea ...
- ABP框架系列之二十四:(Email-Sending-EF-电子邮件发送)
Introduction Email sending is a pretty common task for almost every application. ASP.NET Boilerplate ...
- ABP框架系列之二十六:(EventBus-Domain-Events-领域事件)
In C#, a class can define own events and other classes can register it to be notified when something ...
- ABP框架系列之二十二:(Dynamic-Web-API-动态WebApi)
Building Dynamic Web API Controllers This document is for ASP.NET Web API. If you're interested in A ...
- ABP框架系列之二十八:(Handling-Exceptions-异常处理)
Introduction This document is for ASP.NET MVC and Web API. If you're interested in ASP.NET Core, see ...
- ABP框架系列之二十五:(Embedded-Resource-Files-嵌入式资源文件)
Introduction ASP.NET Boilerplate provides an easy way of using embedded Razor views (.cshtml files) ...
- ABP框架系列之二十九:(Hangfire-Integration-延迟集成)
Introduction Hangfire is a compherensive background job manager. You can integrate ASP.NET Boilerpla ...
随机推荐
- 【转】Maven中-DskipTests和-Dmaven.test.skip=true的区别
主要区别是:是否编译测试类 -DskipTests:编译测试类,但不运行 -Dmaven.test.skip=true:不编译.不运行 转自 http://zephiruswt.blog.51cto. ...
- 机器学习入门-K-means算法
无监督问题,我们手里没有标签 聚类:相似的东西聚在一起 难点:如何进行调参 K-means算法 需要制定k值,用来获得到底有几个簇,即几种类型 质心:均值,即向量各维取平均值 距离的度量: 欧式距离和 ...
- 6 python 继承与派生
1.什么是继承? 继承指的是类与类之间的关系,是一种什么“是”什么的关系,继承的功能之一就是用来解决代码重用问题 继承是一种创建新类的方式,在python中,新建的类可以继承一个或多个父类 父类又可以 ...
- C# 事件 event 【转】
C#事件(event)解析 事件(event),这个词儿对于初学者来说,往往总是显得有些神秘,不易弄懂.而这些东西却往往又是编程中常用且非常重要的东西.大家都知道windows消息处理机制的重要, ...
- CSS选择器学习小结
关于CSS选择器的问题,在实际项目中,以及一般的前端面试中会经常遇到.下面对此做一小结,梳理和巩固相关方面知识.(如有不妥之处,还望大家及时批评指正,以免误导他人) 一.选择器种类 1.id选择器(# ...
- Windows 2008开启远程桌面连接
具体请看下面的截图. 最重要的就是要打开远程允许远程桌面的默认端口 3389 的入站规则,我第一次弄,这一端口没打开,折腾了很久!!! 第一.首先打开“服务器管理器”—“配置”—“高级安全Window ...
- STC-51开发板-单片机控制数码管&按键&点阵综合操作
操作: 实现按下一个按键,对应的数码管和点阵显示相应的数字 代码: /* *******************数码管按键综合项目********************* */ #include ...
- hadoop发行版本
Azure HDInsight Azure HDInsight is Microsoft's distribution of Hadoop. The Azure HDInsight ecosystem ...
- httplib:AttributeError: 'module' object has no attribute 'HTTPConnection'
# -*-coding:gb2312-*- #Function:学习python的httplib模块 import httplib conn = httplib.HTTPConnection(&quo ...
- 浅谈python中的“ ==” 与“ is”
在python中,== 与 is 之间既有区别,又有联系,本文将通过实际代码的演示,力争能够帮助读到这篇文章的朋友以最短的时间理清二者的关系,并深刻理解它们在内存中的实现机制.扯淡的话不多说,下面马上 ...