public static void UpdateDb(Setting setting) { var str = string.Format("Data Source={0};Version=3;", setting.DbPath); var cfg2 = Fluently.Configure() .Database(SQLiteConfiguration.Standard.ConnectionString(str)) .ExposeConfiguration(c => c.Properties.Add("current_session_context_class", typeof(CallSessionContext).FullName)) //.Mappings(x => x.FluentMappings.AddFromAssemblyOf<NewsMap>()) .Mappings(x => x.FluentMappings.AddFromAssembly(setting.Assembly)) .BuildConfiguration(); ////обновим структуру var t = new SchemaUpdate(cfg2); t.Execute(true, true); }
static void Main(string[] args) { if (args.Any(a => a == "help" || a == "?")) { Console.WriteLine("Пример параметров:"); Console.WriteLine("-task update -dll Db.dll"); Console.WriteLine("-task clear -dll Db.dll"); return; } var setting = new Setting(); try { setting.Parse(args); } catch (Exception ex) { Console.WriteLine("Ошибка при чтении параметров.\r\n" + ex); } try { if(setting.Task == Task.Clear) DbAdmin.ClearDb(setting); if (setting.Task == Task.Update) DbAdmin.UpdateDb(setting); Console.WriteLine("Операция выполнена успешно."); } catch (Exception ex) { Console.WriteLine("Ошибка при выполнении операции.\r\n" + ex); Console.WriteLine("InnerException:\r\n" + ex.InnerException); if(ex.InnerException is ReflectionTypeLoadException) { Console.WriteLine("ReflectionTypeLoadException:"); foreach (var loaderEx in (ex.InnerException as ReflectionTypeLoadException).LoaderExceptions) { Console.WriteLine(loaderEx.Message); } } } }