【问题标题】:How to update models in visual studio code from database in Entity Core in asp.net core 5.0如何从 asp.net core 5.0 中 Entity Core 中的数据库更新 Visual Studio 代码中的模型
【发布时间】:2021-06-25 07:48:33
【问题描述】:

到 VS 2017,我创建了一个项目(数据库),一切运行良好。 现在我在 CLI 命令中进行了更改 add new tables(Test) ,问题是如何更新模型以匹配 SQL 中的数据库?

但我不知道如何在编辑数据库后更新模型。添加新表(modelsTest)我使用 CLI 命令

我有参考 dotnet ef dbcontext scaffold 命令的详细信息https://docs.microsoft.com/en-us/ef/core/cli/dotnet#dotnet-ef-dbcontext-scaffold

测试 CLI 命令:

  1. dotnet ef dbcontext 脚手架“服务器=xxx.xxx.xxx.xxx\v11.0;数据库=xxx;Trusted_Connection=True;用户ID=xxxx;密码=xxxxx;集成安全=false;” Microsoft.EntityFrameworkCore.SqlServer -o Models -t modelsTest

2.dotnet ef dbcontext scaffold "Server=xxx;Database=xxx;Trusted_Connection=True;User Id=xxxx;Password=xxxxx;Integrated Security=false;" Microsoft.EntityFrameworkCore.SqlServer -o Models -t modelsTest -f

enter image description here

enter image description here

这是我的项目的截图:

enter image description here

【问题讨论】:

    标签: c# asp.net asp.net-mvc asp.net-core entity-framework-core


    【解决方案1】:

    请注意,differences between Entity Framework 6 and Entity Framework Core (EF Core) 很多,目前 EF Core 中不支持 edmx。

    Feature EF6.4 EF Core
    Model format: EDMX (XML) Yes No support planned

    您引用的命令 dotnet ef dbcontext scaffold 确实适用于 EF Core。

    【讨论】:

      猜你喜欢
      • 2021-03-15
      • 1970-01-01
      • 1970-01-01
      • 2018-02-22
      • 2020-04-15
      • 1970-01-01
      • 2014-05-27
      • 2021-07-22
      • 1970-01-01
      相关资源
      最近更新 更多