Click here to Skip to main content
15,896,512 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Dynamically change grid.mvc in partial view in MVC? Pin
Richard MacCutchan8-Jun-16 20:59
mveRichard MacCutchan8-Jun-16 20:59 
GeneralRe: Dynamically change grid.mvc in partial view in MVC? Pin
dshilpa8-Jun-16 22:30
dshilpa8-Jun-16 22:30 
AnswerRe: Dynamically change grid.mvc in partial view in MVC? Pin
John C Rayan8-Jun-16 22:55
professionalJohn C Rayan8-Jun-16 22:55 
QuestionPost ifram embedded PDF editable document to ASP.Net MVC Post Action Pin
Asjad ali kash8-Jun-16 1:01
Asjad ali kash8-Jun-16 1:01 
Questionsorting of a image column Pin
mrakshay12127-Jun-16 23:56
mrakshay12127-Jun-16 23:56 
QuestionTrying to create database using Code First Approach Pin
indian1437-Jun-16 16:20
indian1437-Jun-16 16:20 
Rant[REPOST] Trying to create database using Code First Approach Pin
Richard Deeming8-Jun-16 1:41
mveRichard Deeming8-Jun-16 1:41 
AnswerRe: Trying to create database using Code First Approach Pin
jkirkerx10-Jun-16 7:56
professionaljkirkerx10-Jun-16 7:56 
Database creation is done in the DBContext after declaring the class. You can tell the DBContext to drop the old database when the Model has changed, or create a new database if there is no database.

You also call an intializer to seed the database with data or images, etc.

So this DBContext will call my initializer:
It will either create a new database, or run a database migration.
public class indigoDBContext : DbContext 
    {

        public indigoDBContext() : base("DefaultConnection")
        {
            // Enable the Intializer
            Database.SetInitializer(new indigoIntializer());
        }

        // CRM
        public DbSet<CRM_ARCHIVES>  CRM_ARCHIVES        { get; set; }

This is my intializer.
class indigoIntializer : CreateDatabaseIfNotExists<indigoDBContext>
    {
        protected override void Seed(indigoDBContext context)
        {
            base.Seed(context);

            // Seed the Website Adminsitrator Table
            siteAdministrators.seed(context);

            // Seed the Website Countries and States
            countries.seed(context);
            states_Provinces.seed(context);
            salesTax.seed(context);
            avatars.seed(context);
            themes.seed(context);
            paymentGateways.seed(context);
            paymentBrands.seed(context);

        }
    }
class Configuration : DbMigrationsConfiguration<indigoDBContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = true;
        ContextKey = "Indigo.DataAccessLayer.indigoDBContext";
    }

    protected override void Seed(Indigo.DataAccessLayer.indigoDBContext context)
    {
        base.Seed(context);

        // Seed the Website Adminsitrator Table
        siteAdministrators.seed(context);

        // Seed the Website Countries and States
        countries.seed(context);
        states_Provinces.seed(context);
        salesTax.seed(context);
        avatars.seed(context);
        themes.seed(context);
        paymentGateways.seed(context);
        paymentBrands.seed(context);
    }
}

So when you change the database model, you have to either delete the database and start again or run a migration in package manager (command line) within Visual Studio, migrations add update_today for an example, then migration save.

update_today would be a code function in the DBContext that's sort of like a seed command, in which it uses code to change the database table to the new version.

I prefer to delete the database and start all over again. This ensures that my seed functions work well, the setup programs work when starting from scratch. Then when complete of ready for release, use migration and version control and keep existing data.

All of this runs automatically as soon as you make a DBcontext. The migrations you run manually, unless I can figure out how to run them using npm in the build event.
QuestionWhat is Diffrent between hash table and dictionary Pin
jitendra jayswal7-Jun-16 1:26
jitendra jayswal7-Jun-16 1:26 
SuggestionRe: What is Diffrent between hash table and dictionary Pin
Richard MacCutchan7-Jun-16 3:23
mveRichard MacCutchan7-Jun-16 3:23 
QuestionUsing Webgrease, Best Practices, vs Gulp and Bower Pin
jkirkerx5-Jun-16 12:26
professionaljkirkerx5-Jun-16 12:26 
AnswerI decided to dump Webgrease and the bundle, and use Gulp, bower, git and node to automate the task. Pin
jkirkerx6-Jun-16 9:19
professionaljkirkerx6-Jun-16 9:19 
QuestionGoogle map with multiple marked location Pin
Member 118050633-Jun-16 3:38
Member 118050633-Jun-16 3:38 
AnswerRe: Google map with multiple marked location Pin
ZurdoDev3-Jun-16 4:40
professionalZurdoDev3-Jun-16 4:40 
QuestionHttpWebRequest authentication problem Pin
candogu2-Jun-16 3:07
candogu2-Jun-16 3:07 
AnswerRe: HttpWebRequest authentication problem Pin
ZurdoDev2-Jun-16 3:14
professionalZurdoDev2-Jun-16 3:14 
GeneralRe: HttpWebRequest authentication problem Pin
candogu2-Jun-16 3:16
candogu2-Jun-16 3:16 
GeneralRe: HttpWebRequest authentication problem Pin
ZurdoDev2-Jun-16 3:19
professionalZurdoDev2-Jun-16 3:19 
AnswerRe: HttpWebRequest authentication problem Pin
John C Rayan2-Jun-16 3:18
professionalJohn C Rayan2-Jun-16 3:18 
AnswerRe: HttpWebRequest authentication problem Pin
F-ES Sitecore2-Jun-16 4:24
professionalF-ES Sitecore2-Jun-16 4:24 
QuestionAsp.Net MVC View, Loading HTML in iframe element instead of src=url Pin
jkirkerx1-Jun-16 11:25
professionaljkirkerx1-Jun-16 11:25 
AnswerRe: Asp.Net MVC View, Loading HTML in iframe element instead of src=url Pin
Richard Deeming2-Jun-16 2:21
mveRichard Deeming2-Jun-16 2:21 
GeneralRe: Asp.Net MVC View, Loading HTML in iframe element instead of src=url Pin
jkirkerx2-Jun-16 6:36
professionaljkirkerx2-Jun-16 6:36 
GeneralRe: Asp.Net MVC View, Loading HTML in iframe element instead of src=url Pin
jkirkerx2-Jun-16 8:26
professionaljkirkerx2-Jun-16 8:26 
GeneralRe: Asp.Net MVC View, Loading HTML in iframe element instead of src=url Pin
Richard Deeming2-Jun-16 8:37
mveRichard Deeming2-Jun-16 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.