public static void UseSeedDataMildd(this IApplicationBuilder app, MySqlContext mySqlContext, string webRootPath) { if (app == null) { throw new ArgumentNullException(nameof(app)); } try { if (AppSettings.app("AppSettings", "SeedDB").ObjToBool() || AppSettings.app("AppSettings", "SeedDBData").ObjToBool()) { DBSeed.SeedAsyncByEFCore(mySqlContext, webRootPath).Wait(); } } catch (Exception e) { throw new Exception($"自动初始化数据错误,错误信息:\n{e.Message}"); } }
public static void UseSeedDataMildd(this IApplicationBuilder app, MyContext myContext, MySqlContext mySqlContext, string webRootPath) { if (app == null) { throw new ArgumentNullException(nameof(app)); } try { if (AppSettings.app("AppSettings", "SeedDBEnabled").ObjToBool() || AppSettings.app("AppSettings", "SeedDBDataEnabled").ObjToBool()) { //DBSeed.SeedAsync(myContext, webRootPath).Wait(); DBSeed.SeedAsyncByEFCore(mySqlContext, webRootPath).Wait(); } } catch (Exception e) { throw new Exception($"Error occured seeding the Database.\n{e.Message}"); } }