37

I'm trying to launch .Net Core 2.0 application on Ubuntu 17.04. I developed it on Windows 10 before and it works well. The problem is that when I run dotnet ef database update I get the next exception:

System.PlatformNotSupportedException: LocalDB is not supported on this Platform.

Here is my DbContext:

public class NutritionContext : DbContext
{
    public DbSet<User> Users { get; set; }
    public DbSet<Meal> Meals { get; set; }
    public DbSet<Dish> Dishes { get; set; }
    public DbSet<Product> Products { get; set; }
    public DbSet<Plan> Plans { get; set; }
    public DbSet<MealDish> MealDishes { get; set; }
    public DbSet<Ingredient> Ingredients { get; set; }
    public DbSet<PlanDetail> PlanDetails { get; set; }
    public DbSet<UserPlan> UserPlans { get; set; }
    public DbSet<AuthUser> AuthUsers { get; set; }

    public NutritionContext()
    {
    }

    public NutritionContext(DbContextOptions options) : base(options)
    {           
    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlServer(
            "Server=(localdb)\\mssqllocaldb;Database=NutritionDatabaseNew;Trusted_Connection=True;MultipleActiveResultSets=true");
    }

}

Do you know what could be the reason of it?

3
  • It's not possible.
    – Sinatr
    Commented Aug 24, 2017 at 11:57
  • 3
    The work around, do not use LocalDB on that platform. Use a different database provider instead. There is nothing else that can be said or done about it (short of you joining the Microsoft db development team and add functionality to make LocalDB compatible with this platform)
    – Igor
    Commented Aug 24, 2017 at 11:58
  • 1
    ok thanks, I didn't know I can't use LocalDB on ubuntu
    – YTerle
    Commented Aug 24, 2017 at 12:05

4 Answers 4

43

LocalDb is a packaging mechanism for SQL Server Express Edition, and is only available for Windows. On Ubuntu you can install regular SQL Server Express Edition.

https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-overview

Here are the install scripts for Ubuntu, Red Hat, and SUSE.

Or use the Docker Images:

https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker

2
  • sorry @david-browne-microsoft, Did u meant to say "On Ubuntu you can install regular SQL Server E̶x̶p̶r̶e̶s̶s Edition." ?
    – Ruslan
    Commented Jul 22, 2020 at 12:10
  • LocalDb is a flavor of Express Edition, but you can install any edition with the Linux installer or docker image. Commented Jul 22, 2020 at 13:22
8

I had this problem when switching from a windows machine to MacBook Pro. As others pointed out, LocalDB is for SQL Server Express Edition (available for windows).

To fix this, you'll need to install SQL Server and use localhost instead of LocalDB.

5

I had a problem with running Asp.Net Core 6 web application on Ubuntu V 20.04 (with sqlserver installed locally on ubuntu). enter image description here

I have a connection string set enter image description here

To Fix this: I had to change my connection string to explicitly specify userid and password set Encrypt=false. Also instead of (localdB) I have to use localhost in my connection string See more information here

"Server=localhost;Database=BethanysPieShop8854;User Id=sa;Password=passw0rd!;MultipleActiveResultSets=true;Encrypt=false"

4
  • That's not the same issue. It's about localDb here, that's not the same as "sqlserver 2022 installed locally on ubuntu". Commented Mar 1, 2023 at 17:22
  • Sorry I forgot to mention I have to change (localdb) to localhost also in my connection string
    – Hemendr
    Commented Mar 1, 2023 at 17:32
  • Look, you're just running SQL server, not localDb. Whatever you put in the connection string wrongly, it has nothing to do with the question. Commented Mar 2, 2023 at 10:53
  • 1
    Don't know but I exactly face the same issue when I successfully ran my asp.net core application using SQL server on windows and then I ran the same source code on Linux Ubuntu with sqlserver installed and I received the same message "Local DB is not supported on this Platform". I fixed the issue by changing my connection string only and shared my answer the way I solved.
    – Hemendr
    Commented Mar 2, 2023 at 11:20
0

For Linux systems based on Arch the mssql-server package seems to be the way to go.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.