首页 > 解决方案 > 如何使用“dotnet ef 脚手架”从 sqlite 数据库创建模型?

问题描述

本教程只告诉我如何使用 SQL 数据库。

dotnet ef dbcontext scaffold "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models -t Blog -t Post --context-dir Context -c BlogContext

标签: entity-frameworksqlite

解决方案


  • 安装 .NET Core CLI
  • 安装 Ef 工具

    dotnet 工具安装 --global dotnet-ef

  • 确保在您的项目中安装 Microsoft.EntityFrameworkCore.Designer 和 Microsoft.EntityFrameworkCore.Sqlite

  • 从项目文件夹运行命令:

    dotnet ef dbcontext 脚手架“数据源=C:\dbPath\db.sqlite”Microsoft.EntityFrameworkCore.Sqlite --output-dir DataModel


推荐阅读