コード例 #1
0
        public static void Initialize(bool populateSeedData = true)
        {
            //delete existing db
            var context = new WwfdContext();

            context.Database.Delete();

            //create new db from scratch
            context.Database.Initialize(true);

            //seed the lookup tables
            context.CreateLookupForEnum <Enums.FounderRoleType>();
            context.CreateLookupForEnum <Enums.ContributorRoleType>();
            context.CreateLookupForEnum <Enums.QuoteHistoryType>();
            context.CreateLookupForEnum <Enums.QuoteStatusType>();
            context.CreateLookupForEnum <Enums.QuoteReferenceStatusType>();
            context.CreateLookupForEnum <Enums.DailyQuoteProcessStatusType>();

            //setup advanced stuff
            SetupExtendedOptions(context);

            //populate db with data if requested
            if (populateSeedData)
            {
                PopulateSeedData(context);
            }
        }
コード例 #2
0
 private static void PopulateSeedData(WwfdContext context)
 {
     context.Database.ExecuteSqlCommand(GetResourceSqlScript("Wwfd.Data.CodeFirst.Scripts.SeedContributors.sql"));
     context.Database.ExecuteSqlCommand(GetResourceSqlScript("Wwfd.Data.CodeFirst.Scripts.SeedFounders.sql"));
     context.Database.ExecuteSqlCommand(GetResourceSqlScript("Wwfd.Data.CodeFirst.Scripts.SeedQuotes.sql"));
     context.Database.ExecuteSqlCommand(GetResourceSqlScript("Wwfd.Data.CodeFirst.Scripts.SeedQuoteHistories.sql"));
     context.Database.ExecuteSqlCommand(GetResourceSqlScript("Wwfd.Data.CodeFirst.Scripts.SeedQuoteReferences.sql"));
 }
コード例 #3
0
        private static void SetupExtendedOptions(WwfdContext context)
        {
            //full text searching
            context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, GetResourceSqlScript("Wwfd.Data.CodeFirst.Scripts.SetupFullText.sql"));

            //triggers
            context.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, GetResourceSqlScript("Wwfd.Data.CodeFirst.Scripts.SetupTriggers.sql"));

            //disable lazyloading (should be default)
            context.Configuration.LazyLoadingEnabled = false;
        }