mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Fix multiple migration sets.
This commit is contained in:
parent
62fcb60279
commit
14c05c3c43
@ -13,7 +13,7 @@ namespace Remotely.Server.Data
|
||||
{
|
||||
public class ApplicationDbContext : IdentityDbContext
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> context)
|
||||
public ApplicationDbContext(DbContextOptions context)
|
||||
: base(context)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Npgsql;
|
||||
using System;
|
||||
@ -12,7 +13,7 @@ namespace Remotely.Server.Data
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public PostgreSqlDbContext(DbContextOptions<ApplicationDbContext> context, IConfiguration configuration)
|
||||
public PostgreSqlDbContext(DbContextOptions context, IConfiguration configuration)
|
||||
: base(context)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@ -12,7 +12,7 @@ namespace Remotely.Server.Data
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public SqlServerDbContext(DbContextOptions<ApplicationDbContext> context, IConfiguration configuration)
|
||||
public SqlServerDbContext(DbContextOptions context, IConfiguration configuration)
|
||||
: base(context)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -11,7 +12,7 @@ namespace Remotely.Server.Data
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public SqliteDbContext(DbContextOptions<ApplicationDbContext> context, IConfiguration configuration)
|
||||
public SqliteDbContext(DbContextOptions context, IConfiguration configuration)
|
||||
: base(context)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@ -10,8 +10,8 @@ using Remotely.Server.Data;
|
||||
namespace Remotely.Server.Migrations.PostgreSql
|
||||
{
|
||||
[DbContext(typeof(PostgreSqlDbContext))]
|
||||
[Migration("20201002211851_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20201005051254_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace Remotely.Server.Migrations.PostgreSql
|
||||
{
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
@ -86,6 +86,7 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\PostgreSql\" />
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -43,9 +43,7 @@ namespace Remotely.Server
|
||||
var dbProvider = Configuration["ApplicationOptions:DBProvider"].ToLower();
|
||||
if (dbProvider == "sqlite")
|
||||
{
|
||||
services.AddDbContext<SqliteDbContext>();
|
||||
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
services.AddDbContext<ApplicationDbContext, SqliteDbContext>(options =>
|
||||
options.UseSqlite(Configuration.GetConnectionString("SQLite")));
|
||||
|
||||
services.AddIdentity<RemotelyUser, IdentityRole>(options => options.Stores.MaxLengthForKeys = 128)
|
||||
@ -55,8 +53,7 @@ namespace Remotely.Server
|
||||
}
|
||||
else if (dbProvider == "sqlserver")
|
||||
{
|
||||
services.AddDbContext<SqlServerDbContext>();
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
services.AddDbContext<ApplicationDbContext, SqlServerDbContext>(options =>
|
||||
options.UseSqlServer(Configuration.GetConnectionString("SQLServer")));
|
||||
|
||||
|
||||
@ -67,8 +64,7 @@ namespace Remotely.Server
|
||||
}
|
||||
else if (dbProvider == "postgresql")
|
||||
{
|
||||
services.AddDbContext<PostgreSqlDbContext>();
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
services.AddDbContext<ApplicationDbContext, PostgreSqlDbContext>(options =>
|
||||
{
|
||||
// Password should be set in User Secrets in dev environment.
|
||||
// See https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-3.1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user