MySql Scaffolding an Existing Database in EF Core
官方文档详见:https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core-scaffold-example.html
Scaffolding a Database Using Package Manager Console in Visual Studio
Open Visual Studio and create a new Console App (.NET Core) for C#.
Add the MySQL NuGet package for EF Core using the Package Manager Console. For example, use the following command to add the
MySql.Data.EntityFrameworkCore v8.0.13package:Install-Package MySql.Data.EntityFrameworkCore -Version 8.0.13NoteThe version (for example,
-v 8.0.13) must match the actual Connector/NET version you are using. For current version information, seeTable 9.2, “Supported versions of Entity Framework Core”.Install the following NuGet packages by selecting either Package Manager Console or Manage NuGet Packages for Solution from the Tools and then NuGet Package Manager menu:
Microsoft.EntityFrameworkCore.DesignEF Core 1.1 only: Also add the
MySql.Data.EntityFrameworkCore.Designpackage.Microsoft.EntityFrameworkCore.Tools version 1.1.6(for EF Core 1.1) andMicrosoft.EntityFrameworkCore.Tools version 2.0.3(for EF Core 2.0)NoteThe .NET tools are included in the .NET Core 2.1 SDK and not required or supported for EF Core 2.1. If this is an upgrade, remove the reference to that package from the .
csprojfile (version 2.0.3 in this example) :<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
Open Package Manager Console and enter the following command at the prompt to create the entities and DbContext for the
sakiladatabase (adjust the connection-string values to match your settings for theuser=andpassword=options):Scaffold-DbContext "server=localhost;port=3306;user=root;password=mypass;database=sakila" MySql.Data.EntityFrameworkCore -OutputDir sakila -fVisual Studio creates a new
sakilafolder inside the project, which contains all the tables mapped to entities and thesakilaContext.csfile.
MySql Scaffolding an Existing Database in EF Core的更多相关文章
- SQLite EF Core Database Provider
原文链接 This database provider allows Entity Framework Core to be used with SQLite. The provider is mai ...
- EF core 性能调优
Entity Framework Core performance tuning – a worked example Last Updated: February 25, 2019 | Create ...
- EF Core Model更新迁移
EF Core 迁移 感觉就是以前EF Code First的自动同步数据库功能 内容:在你新增.更新TableModel后,如何自动化的更新DB中的真实Table.以及对这些更改进行一个版本控制. ...
- Asp.net core 学习笔记 ( ef core )
更新 : 2018-11-26 这里记入一下关于 foreignKey cascade action 默认情况下如果我们使用 data annotation required + foreginkey ...
- .net Core 基于EF Core 实现数据库上下文
在做项目时,需要将某一些功能的实体建立在另一个数据库中,连接不同的数据库用以存储记录.通过查找资料,实现EF Core上下文. 下面是实现上下文后的解决方案的目录: 1.UpAndDownDbCont ...
- Asp.net Core 通过 Ef Core 访问、管理Mysql
本文地址:http://www.cnblogs.com/likeli/p/5910524.html 环境 dotnet Core版本:1.0.0-preview2-003131 本文分为Window环 ...
- MySQL官方.NET Core驱动已出,支持EF Core
千呼万唤始出来MySQL官方.NET Core驱动已出,支持EF Core. 昨天MySQL官方已经发布了.NET Core 驱动,目前还是预览版,不过功能已经可用. NuGet 地址:https:/ ...
- ASP.NET Core 开发-Entity Framework (EF) Core 1.0 Database First
ASP.NET Core 开发-Entity Framework Core 1.0 Database First,ASP.NET Core 1.0 EF Core操作数据库. Entity Frame ...
- net Core 通过 Ef Core 访问、管理Mysql
net Core 通过 Ef Core 访问.管理Mysql 本文地址:http://www.cnblogs.com/likeli/p/5910524.html 环境 dotnet Core版本:1. ...
随机推荐
- Probability和Likelihood的区别
Bayes for Beginners: Probability and Likelihood 好好看,非常有用. 以前死活都不理解Probability和Likelihood的区别,为什么这两个东西 ...
- 20190315xlVBA_删除无用的区域
'经常遇见天眼查表格文件特别大,原因是使用了整个表格,虽然无法解释为什么,但是经过验证以下代码是凑效的 Private Sub DeleteUselessRegion(ByVal sht As Wor ...
- C#集合类型大揭秘
集合是.NET FCL(Framework Class Library)的重要组成部分,我们平常撸C#代码时免不了和集合打交道,FCL提供了丰富易用的集合类型,给我们撸码提供了极大的便利.正是因为这种 ...
- 7.2 GRASP原则二:信息专家 Information Expert
2.GRASP原则二:信息专家 Information Expert What is a general principle of assigning responsibility to obje ...
- xxx征集系统项目目标文档
分组:每四人一组 主题:xxx征集系统 成果: 讨论结束后,每组提交一份课堂讨论记录(电子版发表到博客上,纸质版小组成员签名,下节课提交). 每人根据课堂讨论结果提交一份系统利益相关者描述案例.撰写项 ...
- YII实现restful,postman进行接口测试
Yii2 restful API文档 一.配置模块: 1.Config/main.php: 2.创建模块目录: 3.Module.php: 二.路由配置: 三.控制器: 四.Models: 五.测试: ...
- 【lintcode17/18】Subset, SubsetII
题目:给定一个含不同整数的集合,返回其所有的子集. 样例:如果 S = [1,2,3],有如下的解:[[3],[1],[2],[1,2,3],[1,3],[1,2],[2,3],[]] 思路:因为此题 ...
- Python3+getopt解析命令行参数
一.说明 在学C语言的时候就知道可以通过argc获取命令行参数个数,可以通过argv获取具体参数.但自己写的程序获取到的参数一是没有键值形式二是写的参数不能乱序,和系统命令不太一样. 再往后点知道有g ...
- ES5和ES6那些你必须知道的事儿(一)
ES5和ES6那些你必须知道的事儿 ES5新增的东西 一.数组方法 1.forEach 用途:遍历,循环 对于空数组不会执行回调函数 //用法 array.forEach( function( ...
- Win10系列:C#应用控件基础19
ScrollViewer控件 ScrollViewer控件包含一个水平和一个竖直滚动条以及一个可滚动的内容显示区域,在显示区域内可以放置其他可见控件.ScrollViewer控件的水平和垂直滚动条两端 ...