How do I share a Sqlite database between my desktop and laptop?

Rod Falanga 591 Reputation points
2025-04-19T13:27:12.5066667+00:00

I'm writing a Minimal API application using .NET 9. I started this on my laptop, then committed the changes to my GitHub repo and tried to pick up where I left off on my desktop. However, when I tried to test it using Postman to retrieve the dishes of a fictional business, I got the error:

No such table: Dishes

The tutorial I'm following uses a Sqlite database. I've created it on my laptop and expected it to work on my desktop, but it doesn't. I put this code snippet into the Program.cs file:

using (var serviceScope = app.Services.GetService<IServiceScopeFactory>()?.CreateScope())
{
    var context = serviceScope?.ServiceProvider.GetRequiredService<MyDishesDbContext>();
    context?.Database.EnsureDeleted();
    context?.Database.Migrate();
}

I think the problem is the Sqlite database that I generated using EF Core migrations on my laptop, doesn't appear to be in my desktop. How do I get that Sqlite database to be in both places? Or if that's not the issue, then what is the issue and how do I resolve it?

ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
414 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 74,936 Reputation points
    2025-04-19T15:28:05.17+00:00

    SQLite is a local database file. Unless it’s read only, two applications can not access the same database file concurrently. If you created the db file it on your laptop, you need to copy it to the desktop. If the desktop changes the file, you would need to copy it back to the laptop to see the changes on the laptop.

    if you want the desktop and laptop to share access to a SQLite database, you should create a webapi application that hosts the database on a computer they can both access. Then the laptop and desktop could call the same webapi.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.