Exemple #1
0
        /// <summary>
        /// Initializes persistent storage with at least single SuperAdmin (at production).
        /// For debugging, adds dummy users and data.
        /// <para>Enable context.Database.EnsureDeleted() to force full reseeding with each run.</para>
        /// </summary>
        public async Task Initialize(bool UseStoreProc = true)
        {
#if DEBUG
            // WARNING! Wipes the entire database.
            //context.Database.EnsureDeleted();
#endif
            //make sure DB is created
            bool isDbFresh = context.Database.EnsureCreated();

            await EnsureCompetentSuperAdmin();

#if DEBUG
            if (isDbFresh)
            {
                if (UseStoreProc)
                {
                    await StoreProcFuncRepository.LoadAllToDb(context);
                }
                await SeedDummyData();
            }
#else
            if (UseStoreProc)
            {
                await StoreProcFuncRepository.DeleteAllFromDb(context);

                await StoreProcFuncRepository.LoadAllToDb(context);
            }
#endif
        }
Exemple #2
0
 public async Task RunAsync()
 {
     if (context.Database.EnsureCreated())
     {
         await StoreProcFuncRepository.LoadAllToDb(context);
         await SetRolesAsync();
         await SeedDataAsync();
     }
 }