asp.netazureentity-frameworksqlitevisual-studio-2019

"Entity framework SQL Script generation failed" error occurs while publishing on azure using SQLite Database


I found a lot of questions similar to my problem on MSDN and SF but none of them helped me or maybe I didn't understand them. I'm getting the following error while I'm trying to publish my app on Azure.

Entity framework SQL Script generation failed

I'm using the SQLite database here. Point to be noted that everything is ok in my local machine. The app runs fine.

I already ran these commands on package manager console - Add-Migration -Initial and Update-Database

Publishing setting

enter image description here

In this photo, I entered "Initial" as the connection string in the EF Migrations field. The result is the same. Maybe the problem causing here I guess.

appsetting.json

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "EmployeeDB": "Data Source=employeedb.db;"
  }
}

Solution

  • I think this could help you if you got an Azure App Service running. I had been searching so long for fix this issue. I was able to resolve the issue using Server Explorer from the Visual Studio 2019 Community Edition.

    Before you start, you need to deploy your app without migrations, deselect Entity Framework Migrations on your Publish Profile settings, and then publish your Azure profile.

    1. On Visual Studio Community 2019, log into your Azure Account under Server Explorer -> Azure
    2. Select App Service and double-click on Open Cloud Explorer
    3. A new tab window appears and you'll need to find your Azure Subscription
    4. Within your Azure Subscription, you'll see all your App Services
    5. Within one, go to the Files folder and you´ll see all of your deployed files
    6. Right click on the Files folder and select Upload File
    7. Upload your .db file in this window

    Server Explorer is usually at left toolbar

    This where you can find your deployed files