Код: Выделить всё
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string MiddelName { get; set; }
public string LastName { get; set; }
public bool IsActive { get; set; }
public DateTime? DateAdded { get; set; }
}
public class DataContext : IdentityDbContext
{
public DataContext(DbContextOptions options) : base(options) {}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
//AspNetUsers -> User
modelBuilder.Entity()
.ToTable("User");
//AspNetRoles -> Role
modelBuilder.Entity()
.ToTable("Role");
//AspNetUserRoles -> UserRole
modelBuilder.Entity()
.ToTable("UserRole");
//AspNetUserClaims -> UserClaim
modelBuilder.Entity()
.ToTable("UserClaim");
//AspNetUserLogins -> UserLogin
modelBuilder.Entity()
.ToTable("UserLogin");
}
}
Код: Выделить всё
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext(x => x.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseMvc();
}
}
"Найдено более одного DbContext. Укажите, какой из них использовать. Используйте параметр '-Context' для команд PowerShell и параметр '--context' для команд dotnet."
Как это можно решить?
Подробнее здесь: https://stackoverflow.com/questions/523 ... -was-found
Мобильная версия