예제 #1
0
        /// <summary>
        /// This will wipe and create a new database - which takes some time
        /// </summary>
        /// <param name="onlyIfNoDatabase">If true it will not do anything if the database exists</param>
        /// <returns>returns true if database database was created</returns>
        public static bool WipeCreateSeed(bool onlyIfNoDatabase)
        {
            using (var db = new ConceptQueryContext())
            {
                if (onlyIfNoDatabase && (db.GetService <IDatabaseCreator>() as RelationalDatabaseCreator).Exists())
                {
                    return(false);
                }

                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();
                if (!db.ReadonlyConcepts.Any())
                {
                    WriteTestData(db);
                }
            }
            return(true);
        }
예제 #2
0
        public static void WriteTestData(this ConceptQueryContext db)
        {
            //ReadonlyConcept[] concepts = new[]
            //{
            //    new ReadonlyConcept
            //    {
            //        Id = 0,
            //        Super = "color",
            //        Sub = "red"
            //    },
            //    new ReadonlyConcept
            //    {
            //        Id = 1,
            //        Super = "color",
            //        Sub = "blue"
            //    }
            //};

            //db.ReadonlyConcepts.AddRange(concepts);
            //db.SaveChanges();
        }