private static void CreateDatabase() { string fileName; string connectionString = ConnectionStringMethods.GetConnectionString(out fileName); using (File.Create(fileName)) { //SqlCe is happy to work with a 0 byte file. } IComparer <string> propertyNameComparer = Comparer <string> .Create(Program.ComparePropertyNames); using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { connection.Open(); foreach (PropertyInfo property in typeof(DataContext).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(property => property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(DbSet <>))) { Program.CreateTable(connection, property.PropertyType.GetGenericArguments()[0], propertyNameComparer); } } }
private static void Main() { string fileName; ConnectionStringMethods.GetConnectionString(out fileName); if (!File.Exists(fileName)) { Console.WriteLine("Can not locate database, be sure to run the Loader!"); Environment.Exit(1); } try { using (IWindsorContainer container = new WindsorContainer()) { container.Install(FromAssembly.InThisApplication()); HostFactory.Run(Program.TopshelfConfiguration(container)); } } catch (Exception e) { Console.WriteLine(e); Console.ReadKey(); } }