protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <ApplicationDbContext, AutomaticMigrationsConfiguration>());

            RegisterConventions(modelBuilder);

            List <Type> typeToRegisters = new List <Type>();

            foreach (var module in GlobalConfiguration.Modules)
            {
                typeToRegisters.AddRange(TypeLoader.FromAssemblies(Assembly.Load(module.AssemblyName)));
            }

            RegisterCustomMapping(modelBuilder, typeToRegisters);

            RegisterEntities(modelBuilder, typeToRegisters);

            modelBuilder.Entity <Brand>().ToTable("Brand");
            modelBuilder.Entity <UrlSlug>().ToTable("UrlSlug");
            modelBuilder.Entity <Category>().ToTable("Category");
            modelBuilder.Entity <Product>().ToTable("Product");
            modelBuilder.Entity <ProductCategory>().ToTable("ProductCategory");
            modelBuilder.Entity <ProductMedia>().ToTable("ProductMedia");
            modelBuilder.Entity <Media>().ToTable("Media");

            base.OnModelCreating(modelBuilder);
        }