代码之家  ›  专栏  ›  技术社区  ›  Athenixz

Azure visual studio发布实体框架迁移错误

  •  1
  • Athenixz  · 技术社区  · 2 年前

    我尝试将网站发布到Azure,但遇到错误:

    the error

    我不知道怎么解决。

    我尝试安装它,但遇到了更多错误:

    nuget install window

    我也试过了 cmd 但仍然没有运气。

    command prompt

    现在我不知道该怎么办。

    我该怎么解决这个问题?

    我正在使用本教程 Youtube link

    我正尝试在Azure上发布具有数据库功能的网站

    another command

    0 回复  |  直到 2 年前
        1
  •  0
  •   Pravallika KV    2 年前

    要安装Entity Framework 8.0,您需要。NET SDK 8.0版本。

    通过运行以下命令检查.NET版本 dotnet --info 在终端。

    C:\Users\username\>dotnet --info
    .NET SDK:
     Version:           8.0.100
     Commit:            57efcf1350
     Workload version:  8.0.100-manifests.71b9f198
    
    Runtime Environment:
     OS Name:     Windows
     OS Version:  10.0.22621
     OS Platform: Windows
     RID:         win-x64
     Base Path:   C:\Program Files\dotnet\sdk\8.0.100\
    
    .NET workloads installed:
     Workload version: 8.0.100-manifests.71b9f198
    There are no installed workloads to display.
    
    Host:
      Version:      8.0.0
      Architecture: x64
      Commit:       5535e31a71
    
    .NET SDKs installed:
      6.0.417 [C:\Program Files\dotnet\sdk]
      8.0.100 [C:\Program Files\dotnet\sdk]
    
    .NET runtimes installed:
      Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    
    Other architectures found:
      x86   [C:\Program Files (x86)\dotnet]
        registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
    
    Environment variables:
      Not set
    
    global.json file:
      Not found
    
    Learn more:
      https://aka.ms/dotnet/info
    
    Download .NET:
      https://aka.ms/dotnet/download
    
    • 运行命令 dotnet tool install --global dotnet-ef ,安装。NET 8.0版本。
    • 我可以成功地发出命令。

    enter image description here

    如果问题仍然存在,请导航到 Visual Studio=>Tools=>Options=>Environment=>Preview features =>启用 使用的预览。NET SDK(需要重新启动) .

    enter image description here

    • 请尝试再次运行该命令。

    我可以发表。NET Core web应用程序,即使不安装,也可以将数据库连接到Azure dotnet-ef .

    VS version: 17.8.3
    .NET SDK version: 8.0.100
    

    步骤如下:

    • 克隆了一个样本。NET Core web应用程序 GitHub .

    • 创建了一个发布配置文件,用于将应用程序部署到Azure应用服务(Windows)

    • 发布配置文件之前,请配置 service dependencies=>Connect .

    enter image description here

    • 选择 Azure SQL Database=>Select your SQL Database

    enter image description here

    • 提供您的 数据库连接字符串名称 以及SQL server的所有其他必需详细信息,请单击 下一个=>完成 :

    enter image description here

    • 将建立连接:

    enter image description here

    • 我的发布配置文件的设置:

    enter image description here

    • 能够成功发布web应用程序:

    enter image description here

    • 运行已部署的应用程序:

    enter image description here

    使用以下命令检查数据库:

    1. 从[dbo]中选择*。[__EF迁移历史]

    enter image description here

    1. 从[dbo]中选择*。[__迁移历史]

    enter image description here

    1. 从[dbo]中选择*。[全部]

    enter image description here

    参考文献: