I am doing a project in ASP.NET CORE 1.0.0 and I am using EntityFrameworkCore. I have separate assemblies, and my project structure is as follows:
ProjectSolution
-src
-1 Domain
-Project.Data
-2 Api
-Project.Api
I Project.Apihave a class in myStartup
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ProjectDbContext>();
services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<ProjectDbContext>()
.AddDefaultTokenProviders();
}
DbContext is in my project Project.Data
public class ProjectDbContext : IdentityDbContext<IdentityUser>
{
public ProjectDbContext(DbContextOptions<ProjectDbContext> options) : base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var builder = new ConfigurationBuilder();
builder.SetBasePath(Directory.GetCurrentDirectory());
builder.AddJsonFile("appsettings.json");
IConfiguration Configuration = builder.Build();
optionsBuilder.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection"));
base.OnConfiguring(optionsBuilder);
}
}
When I try to perform the initial migration, I get this error:
" " Project.Api " " Project.Data ". , . DbContextOptionsBuilder. . options.UseSqlServer(connection, b => b.MigrationsAssembly("Project.Api")). , DbContext. "dotnet ef" , . "
, , , Project.Api:
dotnet ef --startup-project../Project.Api --assembly "../../1 Data/Project.Data" migrations add Initial
:
"Unexpected value '../../1 Domain/Project.Data' for option 'assembly'"
, , -assembly.
, , .
- ?