static void Main(string[] args) { DatabaseFacade db = new SQLContext().Database; db.EnsureDeleted(); db.EnsureCreated(); Suggest.SuggestFactory.Create(); Console.WriteLine("AllRight"); }
static void Main(string[] args) { DatabaseFacade db = new SQLContext().Database; db.EnsureDeleted(); //如果存在数据库,就删除 //db.EnsureCreated(); // 什么和Migration冲突 别混合用 db.Migrate(); //返回上一层 RegisterFactory.Create(); NewFactory.Create(); Console.ReadKey(); }
static void Main(string[] args) { string connectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=17bang;Integrated Security=True;"; DbContextOptionsBuilder <SQLContext> optionsBuilder = new DbContextOptionsBuilder <SQLContext>(); optionsBuilder .UseLoggerFactory(consoleLoggerFactory) .UseSqlServer(connectionString); DatabaseFacade db = new SQLContext(optionsBuilder.Options).Database; db.EnsureDeleted(); //如果存在数据库,就删除 db.EnsureCreated(); //和Migration可能冲突,不要混合使用 ////db.Migrate(); RegissterFctory.Create(); //Suggest.NewFactory.Create(); Console.Read(); }