Exemple #1
0
 public DatabaseContext(System.Data.Entity.IDatabaseInitializer <DatabaseContext> initializer)
     : base("name=ConnectionString")
 {
     if (initializer != null)
     {
         System.Data.Entity.Database.SetInitializer <DatabaseContext>(initializer);
     }
 }
Exemple #2
0
        public DatabaseContextSqlServer(System.Data.Entity.IDatabaseInitializer <DatabaseContextSqlServer> initializer = null)
            : base("name=DatabaseContext")
        {
            this.Database.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["DatabaseContext"].ConnectionString;

            //Set the database initializer (by default use CreateDatabaseIfNotExist<DatabaseContext>())
            if (initializer != null)
            {
                System.Data.Entity.Database.SetInitializer <DatabaseContextSqlServer>(initializer);
            }

            this.Configuration.LazyLoadingEnabled = false;
            //this.Database.Log = WriteLog;
        }