private void VerificaDB() { //string dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory") as string; using (PavimentalContext db = new PavimentalContext()) { //Se esiste verifico che sia compatibile if (db.Database.Exists()) { bool compatibile = db.Database.CompatibleWithModel(false); if (!compatibile) { db.Database.Delete(); db.Database.Create(); InitializeDB.InitalizeAll(); } } else { db.Database.Create(); InitializeDB.InitalizeAll(); } //Faccio questa query per ottimizzare le successive var temp = db.ConoscenzaCompetenze.ToList(); } }
protected override void Seed(PavimentalContext context) { base.Seed(context); DbContextAdapter adapter = new DbContextAdapter(context); InitializeDB initializer = new InitializeDB(context); initializer.InitalizeAll(); }
void InizializzaDB() { using (PavimentalContext db = new PavimentalContext()) { db.Database.Delete(); db.Database.Create(); } InitializeDB.InitalizeAll(); }