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 ...
随机推荐
- XE4 TStringDynArray 比 c6 的TStringList 好用 字符串 分解 分割 转换 TByteDynArray
TStringDynArray 动态数组 字符串 分解 分割 System::DynamicArray<System::UnicodeString> TByteDynArray, ...
- Redis 安装 和 启动
Redis下载官网 http://download.redis.io/releases/ 本人下载了stable版 1:安装步骤 ># wget http://download.redis.i ...
- C#怎么判断字符是不是汉字
.用ASCII码判断 在 ASCII码表中,英文的范围是0-,而汉字则是大于127,根据这个范围可以判断,具体代码如下: string text = "我去"; bool res ...
- zset
zset sorted set,有序集合 元素为string类型 元素具有唯一性,不重复 每个元素都会关联一个double类型的score,表示权重,通过权重将元素从小到大排序 说明:没有修改操作 增 ...
- vmadm命令
VMADM(1M)VMADM(1M) 名称 vmadm - 管理SmartOS虚拟机 概要 / usr / vm / sbin / vmadm <command> [-d] [-v] [特 ...
- HttpClient 发送 HTTP、HTTPS
首先说一下该类中需要引入的 jar 包,apache 的 httpclient 包,版本号为 4.5,如有需要的话,可以引一下. 代码 import org.apache.commons.io ...
- Spring boot集成 MyBatis 通用Mapper
配置 POM文件 <parent> <groupId>org.springframework.boot</groupId> <artifactId>sp ...
- MyBatis传入参数
在MyBatis的select.insert.update.delete这些元素中都提到了parameterType这个属性.MyBatis现在可以使用的parameterType有基本数据类型和Ja ...
- 慕课网access_token的获取(下)
接口调用返回的结果是两个字段:access_token和expires_in,所以需要创建一个实体类封装这两个字段 运行测试类WeixinTest.java控制台打印出错误信息 重置开发者密钥试试看 ...
- TensorFlow—CNN—CIFAR数据集分类