#187 configurable database migration
This commit is contained in:
parent
892988155d
commit
a407d03a96
@ -12,6 +12,8 @@ using System;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using RMuseum.Models.MusicCatalogue;
|
||||
using RMuseum.Models.Accounting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.IO;
|
||||
|
||||
namespace RMuseum.DbContext
|
||||
{
|
||||
@ -22,7 +24,13 @@ namespace RMuseum.DbContext
|
||||
{
|
||||
public RMuseumDbContext(DbContextOptions<RMuseumDbContext> options) : base(options)
|
||||
{
|
||||
Database.Migrate();
|
||||
IConfigurationRoot configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
if(bool.Parse(configuration["DatabaseMigrate"]))
|
||||
{
|
||||
Database.Migrate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=museum;Trusted_Connection=True;MultipleActiveResultSets=true"
|
||||
},
|
||||
"DatabaseMigrate": "False",
|
||||
"PictureFileService": {
|
||||
"StoragePath": "C:\\museum",
|
||||
"ResizedImageContentType": "image/jpeg",
|
||||
@ -78,6 +79,6 @@
|
||||
"GDBListXMLFile": "D:\\My Documents\\My Web Design\\ganjoor\\www\\i\\android\\sitepoets.xml"
|
||||
},
|
||||
"WebServiceUrl": "http://localhost:3439",
|
||||
"ReadOnlyMode": "False",
|
||||
"ReadOnlyMode": "False",
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user