此平台不支持 LocalDB [英] LocalDB is not supported on this Platform

查看:32
本文介绍了此平台不支持 LocalDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Ubuntu 17.04 上启动 .Net Core 2.0 应用程序.我之前在 Windows 10 上开发过它,效果很好.问题是当我运行 dotnet ef database update 时,我得到了下一个异常:

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.

这是我的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?

推荐答案

LocalDb 是 SQL Server Express Edition 的打包机制,仅适用于 Windows.在 Ubuntu 上,您可以安装常规的 SQL Server Express Edition.

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://docs.microsoft.com/en-us/sql/linux/sql-server-linux-overview

这里是 Ubuntu 的安装脚本, 红帽SUSE.

或者使用 Docker 镜像:

Or use the Docker Images:

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

这篇关于此平台不支持 LocalDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆