2016-11-07 67 views
1

我有簡單的DbContext單DbSet:EF核心插件遷移不起作用 - 構建失敗

class SimpleDbContext : DbContext 
{ 
    public DbSet<Content> Content { get; set; } 

    public SimpleDbContext() 
    { 
    } 

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 
    { 
     optionsBuilder.UseSqlServer(CloudConfigurationManager.GetSetting("DbConnectionString")); 
    } 
} 

而且我已經創建了asp.net核心(.NET Framework)的項目和類庫的數據訪問層。在包管理器控制檯中,我將數據訪問項目設置爲默認值,並將Web項目設置爲啓動。 我在數據訪問項目上安裝了Microsoft.EntityFrameworkCore.SqlServer和Microsoft.EntityFrameworkCore.Tools。 但是,當我跑了添加遷移命令包經理說:

PM> add-migration test 
This command may fail unless both the targeted project and startup project are ASP.NET Core or .NET Core projects. 
Build failed. 

我想這是因爲我通常使用客戶端庫進行數據訪問。我創建了新的客戶端庫(核心)項目,並做了相同的事情(也更新了project.json - 將Microsoft.EntityFrameworkCore.Tools添加到工具部分,如教程https://docs.efproject.net/en/latest/platforms/full-dotnet/new-db.html中所述)。行:

除非目標項目和啓動 項目都是ASP.NET Core或.NET Core項目,否則此命令可能會失敗。

消失,但Build失敗。

任何人都知道它會是什麼或如何解決它?

回答

0

通過添加.Net Core Client Library項目並將框架更改爲.Net Framework 4.6.1而不是.NETStandart解決此問題

相關問題