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. ...
随机推荐
- mockjs学习
mockjs简单学习与应用,可以满足工作所需就行.*************************************************************************** ...
- Go语言开发Prometheus Exporter示例
一.Prometheus中的基本概念 Prometheus将所有数据存储为时间序列,这里先来了解一下prometheus中的一些基本概念 指标名和标签每个时间序列都由指标名和一组键值对(也称为标签)唯 ...
- linux的基本操作概览
目录 文件路径相关的命令 最重要的一个通配符:* zip相关命令 重定向 三种权限 一些网络操作 安装软件的三种方式 最近开始学习linux的一些基础操作,安装了ubantu 16版本的Linux操作 ...
- java去除表达符号的正则表达式
java 去标点符号正则表达式 博客分类: 小功能 正则表达式标点符号 public static void main(String[] args) {String s = "哈哈!@#W ...
- BFS GPLT L2-016 愿天下有情人都是失散多年的兄妹
题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805061769609216 分析:一开始以为是并查集..... ...
- FileWriter向文件中写入内容
1.创建fileWriter对象 2.写入文件信息 3.关闭流 必须关闭流,否则将不能写入文件中 /** * * @author Administrator * 文件写入对象的使用 * */ publ ...
- html5(七) Web存储
http://www.cnblogs.com/stoneniqiu/p/4206796.html http://www.cnblogs.com/v10258/p/3700486.html html5中 ...
- haxe相关的计划安排
用多少写多少.先从入门开始,再到怎么写DSL解析器.最后自举(只是做个示范而已 在深入haxe的过程中,多少会跟typescript有交集,这些会边走边总结. 因为只是for example,所以这个 ...
- hdu 6069 Counting Divisors(求因子的个数)
Counting Divisors Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Oth ...
- 基于vue的实战步骤
1.脚手架vue-cli安装 npm install -g vue-cli (npm init -f 生成package.json文件) vue init webpack myapp cd myapp ...