Изменил папку нахождения бд
All checks were successful
Build and deploy / Publish image (push) Successful in 1m6s
All checks were successful
Build and deploy / Publish image (push) Successful in 1m6s
This commit is contained in:
@@ -9,6 +9,10 @@ public class DatabaseContext : DbContext
|
|||||||
public DbSet<Specialty> Specialties { get; set; }
|
public DbSet<Specialty> Specialties { get; set; }
|
||||||
public string DbPath { get; }
|
public string DbPath { get; }
|
||||||
|
|
||||||
|
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.Entity<Institut>().HasKey(i => i.Id);
|
modelBuilder.Entity<Institut>().HasKey(i => i.Id);
|
||||||
@@ -37,13 +41,4 @@ public class DatabaseContext : DbContext
|
|||||||
new Specialty() { Id = 10, Name = "Безопасность информационных технологий в правоохранительной сфере", Code = "10.05.05", InstitutId = 1 }
|
new Specialty() { Id = 10, Name = "Безопасность информационных технологий в правоохранительной сфере", Code = "10.05.05", InstitutId = 1 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatabaseContext()
|
|
||||||
{
|
|
||||||
var folder = Environment.SpecialFolder.LocalApplicationData;
|
|
||||||
DbPath = System.IO.Path.Join("./", "database.db");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
||||||
=> options.UseSqlite($"Data Source={DbPath}");
|
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,13 @@ builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
|||||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddDbContext<DatabaseContext>();
|
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
var folder = Path.Join(baseDirectory, "data");
|
||||||
|
if (!Directory.Exists(folder))
|
||||||
|
Directory.CreateDirectory(folder);
|
||||||
|
|
||||||
|
folder = Path.Join(folder, "database.db");
|
||||||
|
builder.Services.AddDbContext<DatabaseContext>(options => options.UseSqlite($"Data Source={folder}"));
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
|
|||||||
Reference in New Issue
Block a user