2

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"));
3
  • did you find a solution? I have the same problem Commented Mar 17, 2018 at 7:11
  • Yes, put the SQLite databases in the "AppData" folder in the .NET Solution directory and point your connection strings to that new location Commented Mar 19, 2018 at 1:13
  • @EmmanuelOgoma Were you able to resolve the problem you were having? Commented Apr 3, 2018 at 15:11

2 Answers 2

2

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"
}
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.