Пример #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = Speedy.Extensions.GetSerializerSettings(true, false);
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
            GlobalConfiguration.Configuration.EnsureInitialized();

            Database.SetInitializer(new MigrateDatabaseToLatestVersion <ScribeSqlDatabase, Configuration>(true));

            var appDataPath = HttpContext.Current.Server.MapPath("~/App_Data");
            var client      = new ScribeDataChannel(new ScribeDatabaseProvider(() => new ScribeSqlDatabase()));
            var provider    = new KeyValueRepositoryProvider <Event>(appDataPath);

            Tracker = Tracker.Start(client, provider);

            using (var datacontext = new ScribeSqlDatabase())
            {
                var siteSettings = SiteSettings.Load(datacontext);

                IsConfigured = datacontext.Users.Any();
                PrintCss     = siteSettings.PrintCss ?? string.Empty;
                ViewCss      = siteSettings.ViewCss ?? string.Empty;
            }
        }
Пример #2
0
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            var builder = modelBuilder.Entity <User>();

            builder.ToTable(nameof(User));
            builder.HasKey(p => p.Id);
            var model = modelBuilder.Build(Database.Connection);
            var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists <EntityContext>(modelBuilder);

            DataBase.SetInitializer(sqliteConnectionInitializer);
            //sqliteConnectionInitializer.InitializeDatabase(this);
            //IDatabaseCreator sqliteDatabaseCreator = new SqliteDatabaseCreator();
            //sqliteDatabaseCreator.Create(Database, model);
        }
Пример #3
0
 public ApplicationDbContext() : base("name=SqlServer")
 {
     Database.SetInitializer(new TodosInitializer());
     //Database.Initialize(true);
 }
Пример #4
0
 static TestHelper()
 {
     Database.SetInitializer(new MigrateDatabaseToLatestVersion <ScribeSqlDatabase, Configuration>(true));
 }
Пример #5
0
 public BgDataContext(string connectionString)
     : base(_sqlConnection = new SQLiteConnection(_connectionString = connectionString), true)
 {
     _sqlConnection.Open();
     Entity.SetInitializer <BgDataContext>(null);
 }
 Setup()
 {
     EFDatabase.SetInitializer <DemoDbContext>(
         new DropCreateDatabaseIfModelChanges <DemoDbContext>());
 }
Пример #7
0
 public AppDbContext()
 {
     Database.SetInitializer <AppDbContext>(null);
     InstanceId = Guid.NewGuid();
 }