简体   繁体   中英

EF Core Add-Migration doesn't work - Build failed

I have simple DbContext with single DbSet:

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

    public SimpleDbContext()
    {
    }

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

Also I have created asp.net core (.net framework) project and class library as data access layer. In Package Manager Console I made data access project as default and web project as start up. I installed Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools on data access project. But when I ran Add-Migration command package manager said:

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.

I thought it's because I use usual Client Library for data access. I created new Client Library (core) project and did the same things(also updated project.json - added Microsoft.EntityFrameworkCore.Tools to tools section as said in tutorial https://docs.efproject.net/en/latest/platforms/full-dotnet/new-db.html ). Line:

This command may fail unless both the targeted project and startup project are ASP.NET Core or .NET Core projects.

Disappeared but Build failed left.

Anyone knows what could it be or how to solve it?

通过添加.Net Core Client Library项目并将框架更改为.Net Framework 4.6.1而不是.NETStandart解决了这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM