C# 此平台不支持LocalDB

C# 此平台不支持LocalDB,c#,database,entity-framework,.net-core,.net-core-2.0,C#,Database,Entity Framework,.net Core,.net Core 2.0,我正试图在ubuntu17.04上启动.netcore2.0应用程序。我以前在Windows10上开发过它,效果很好。问题是,当我运行dotnet ef database update时,会出现下一个异常: System.PlatformNotSupportedException: LocalDB is not supported on this Platform. 这是我的DbContext: public class NutritionContext : DbContext { p

我正试图在
ubuntu17.04
上启动
.netcore2.0
应用程序。我以前在Windows10上开发过它,效果很好。问题是,当我运行
dotnet ef database update
时,会出现下一个异常:

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");
    }

}
公共类NutritionContext:DbContext
{
公共数据库集用户{get;set;}
公共数据库集膳食{get;set;}
公共数据库集{get;set;}
公共数据库集产品{get;set;}
公共数据库集计划{get;set;}
公共DbSet MealDishes{get;set;}
公共数据库集{get;set;}
公共数据库集PlanDetails{get;set;}
公共数据库集用户计划{get;set;}
公共数据库集AuthUsers{get;set;}
公共营养学上下文()
{
}
公共NutritionContext(DbContextOptions选项):基本(选项)
{           
}
配置时受保护的覆盖无效(DBContextOptions Builder Options Builder)
{
optionsBuilder.UseSqlServer(
“Server=(localdb)\\mssqllocaldb;Database=NutritionDatabaseNew;Trusted_Connection=True;MultipleActiveResultSets=True”);
}
}

您知道原因是什么吗?

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

以下是和的安装脚本

或者使用Docker图像:


我从windows机器切换到MacBook Pro时遇到了这个问题。正如其他人指出的,LocalDB是用于sqlserverexpressedition的


若要解决此问题,您需要安装SQL Server并使用localhost而不是LocalDB。

原因是:“此平台不支持LocalDB。”这是错误的。谁告诉你可以在Ubuntu上使用localDB的?解决办法是,不要在那个平台上使用localDB。请改用其他数据库提供程序。关于这一点,除了加入Microsoft db开发团队并添加使LocalDB与此平台兼容的功能外,没有其他可以说或做的事情了。好的,谢谢,我不知道我不能在ubuntuI上使用LocalDB。对不起?这是怎么离题的?当然,这是一个描述性错误,但在多平台工具(如
dotnet
上)上,该错误应该如何直观?我们怎么知道不缺少依赖项呢?对不起@david browne microsoft,你是不是想说“在Ubuntu上你可以安装常规的SQL Server E̶x̶p̶r̶E̶s̶s版本。”?LocalDb是Express Edition的一种风格,但你可以安装任何带有Linux安装程序或docker映像的版本。