惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
Cyberwarzone
Cyberwarzone
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
Martin Fowler
Martin Fowler
T
Tor Project blog
N
Netflix TechBlog - Medium
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
V
Visual Studio Blog
GbyAI
GbyAI
PCI Perspectives
PCI Perspectives
D
DataBreaches.Net
Jina AI
Jina AI
H
Heimdal Security Blog
云风的 BLOG
云风的 BLOG
P
Privacy International News Feed
A
About on SuperTechFans
J
Java Code Geeks
美团技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News | PayPal Newsroom
有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
博客园 - 司徒正美
C
Check Point Blog
T
Threat Research - Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
宝玉的分享
宝玉的分享
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Vercel News
Vercel News
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
Cisco Talos Blog
Cisco Talos Blog
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
Recent Commits to openclaw:main
Recent Commits to openclaw:main
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
Docker
博客园 - Franky
Security Archives - TechRepublic
Security Archives - TechRepublic

博客园 - 不是豆豆

切换 Google Play 国家地区 NuGet 命令行记录 在 UnionTech OS Server 20 Euler 64bit 上安装 docker 环境 在 Windows 7 SP1 或 Windows Server 2008 R2 SP1 系统中安装 ASP.NET Core 10.0 运行时环境 记录各版本 Microsoft Visual C++ Redistributable 官方下载地址 在 PolarDB-PG 上安装 pgvector 扩展 在 microsoft onnxruntime 中使用 arcface model 出错:Invalid input scale: NumDimensions() != 3 在 Windows 下为 PostgreSQL 安装 pgvector 插件 如果两个 Steam 库文件夹中,有相同的两份游戏,这时删除第二份会怎样? 当 linux 主机内存较小运行程序(如 yum update)被 Killed 迁移 Gitea 从 Windows 到 Linux Docker 容器中(使用 SQLite 数据库) 在 SkiaSharp 中对图片进行缩放时,结果锯齿较多的处理方案 在 asp.net core web 项目中,创建项目时因选择容器化部署,未配置 IIS Express 应如何进行修改 如何重置 sftpgo 的管理员密码 微信鸿蒙版 8.0.14 查询 navigator.maxTouchPoints 为 0 导致的 bug 在本地 claude code 中使用 copilot pro 订阅 在安装 miniforge3(conda)环境后,每次启动终端(PowerShell)都非常缓慢的处理方案 在 .net framework 4.8 下,若因为安装或升级了 System.ValueTuple 出现问题 在 Windows 11 系统下,日常使用浏览器(Edge、Chrome)常遇到画面撕裂或浏览器在经切换窗口后显示内容不正常 关于 CVE-2025-55315 漏洞问题查验记录 在 gitea 服务器端查询 lfs 文件占用情况 编写 GKD 规则 在 Windows 下 .net 项目中,使用 ViGEm 模拟游戏手柄 为传统 .net framework 项目切换 nlog 日志 处理过大的 docker 日志 测试支持 PolarDB-X(高度兼容 MySQL) 的客户端图形工具 SteamDeck 重置系统密码教程 新版本 portainer ce 在操作容器时,报错 Forbidden - origin invalid
在 EF Core 中使用传统的 DbFirst 模式
不是豆豆 · 2026-02-04 · via 博客园 - 不是豆豆

现在 DbFirst 叫做 Scaffolding,官方译作反向工程

反正就是以数据库架构为准来生成实体模型

然后 EF Core 也没有官方的图形化工具了,统一使用 cli 来操作

在解决方案对应项目上右键,选择“在终端中打开”,然后在打开的终端中执行以下步骤

1、先在项目中安装对应 nuget 包

dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Design

装完最好先生成下项目

2、执行以下脚本连接数据库并生成对应实体类:

dotnet ef dbcontext scaffold --force --no-onconfiguring --use-database-names --no-pluralize --data-annotations --context YourDBEntities "data source=.;initial catalog=YourDB;integrated security=True;multipleactiveresultsets=True;TrustServerCertificate=True;" Microsoft.EntityFrameworkCore.SqlServer

前名命令固定

--force:替换已有模型文件

--no-onconfiguring:不生成连接字符串到代码中

--use-database-names:按数据库名称建立模型对应名称(否则会自动改为 C# 中命名标准)

--no-pluralize:不要将实体名称自动改为复数形式

 --data-annotations:实体字段标记约束

--context [实体类名]:指定生成的数据库实体类名

[连接字符串]:指定连接字符串

Microsoft.EntityFrameworkCore.SqlServer:连接数据库所用的包名

3、然后就可以看到文件已经生成好了。更多选项和操作,请参见

官方文档:https://learn.microsoft.com/zh-cn/ef/core/managing-schemas/scaffolding/?tabs=dotnet-core-cli