2
votes

The ASP.NET Core 2.0 web application fails when I deploy it to Azure App Service.

This is what is being used in the project.

  • ASP.NET Core 2.0 MVC Web Application
  • Visual Studio 2017 Enterprise
  • SQLite databases
  • Code First Entity Framework
  • Azure App Service

The web application works fine when I run it locally in Visual Studio. The problem results when I publish it to an Azure Web Service it cannot connect to the database. It states the following error when navigating to the deployed web application URL:

SqliteException: SQLite Error 1: 'no such table: Inventory'.

I've tried several times to apply an Update-Migration or an Add-Migration to the database but it will still result in the table not found when deployed to the Azure server.

Here are my SQLite connections defined in the Startup.cs file.

     // Add Inventory DB
        services.AddDbContext<InventoryContext>(options =>
        options.UseSqlite("Data Source=Inventory.db"));

        // Add User DB
        services.AddDbContext<UserContext>(options =>
        options.UseSqlite("Data Source=User.db"));

        // Add Purchase Order DB
        services.AddDbContext<PurchaseOrderContext>(options =>
        options.UseSqlite("Data Source=PurchaseOrder.db"));
2
did you find a solution? I have the same problemEmmanuel Ogoma
Yes, put the SQLite databases in the "AppData" folder in the .NET Solution directory and point your connection strings to that new locationDerek Coppinger
@EmmanuelOgoma Were you able to resolve the problem you were having?Derek Coppinger

2 Answers

2
votes

Following @Derek solution, i modified my connection string on appsettings.json as i am using Configuration.GetConnectionString to fetch the connection string, and moved sqlite db to App_Data folder to wwwroot..

"ConnectionStrings": {
    "MyAppContext": "Data Source=./wwwroot/App_Data/myapp.db"
}
0
votes

Place the SQLite databases in the "AppData" folder in the .NET Solution directory and point your connection strings to that new location.