namespace HealthchoiceMVC.Migrations { using System; using System.Data.Entity.Migrations; public partial class _20190903a : DbMigration { public override void Up() { CreateTable( "dbo.ContactClass", c => new { ContactClassId = c.Int(nullable: false, identity: true), Description = c.String(nullable: false, maxLength: 50), }) .PrimaryKey(t => t.ContactClassId); CreateTable( "dbo.PersonContact", c => new { PersonContactId = c.Int(nullable: false, identity: true), PersonId = c.Int(nullable: false), ContactTypeId = c.Int(nullable: false), ContactClassId = c.Int(nullable: false), AlternativeClass = c.String(maxLength: 50), ContactValue = c.String(nullable: false, maxLength: 250), IsValidated = c.Boolean(nullable: false), DateValidated = c.DateTime(nullable: false), }) .PrimaryKey(t => t.PersonContactId) .ForeignKey("dbo.ContactClass", t => t.ContactClassId, cascadeDelete: true) .ForeignKey("dbo.ContactType", t => t.ContactTypeId, cascadeDelete: true) .ForeignKey("dbo.Person", t => t.PersonId, cascadeDelete: true) .Index(t => t.PersonId) .Index(t => t.ContactTypeId) .Index(t => t.ContactClassId); CreateTable( "dbo.ContactType", c => new { ContactTypeId = c.Int(nullable: false, identity: true), Description = c.String(nullable: false, maxLength: 50), Validator = c.String(nullable: false, maxLength: 10), }) .PrimaryKey(t => t.ContactTypeId); CreateTable( "dbo.Person", c => new { PersonId = c.Int(nullable: false, identity: true), TitleId = c.Int(), FirstName = c.String(nullable: false, maxLength: 150), MiddleName = c.String(maxLength: 250), LastName = c.String(nullable: false, maxLength: 150), DateofBirth = c.DateTime(nullable: false), IDTypeId = c.Int(), Gender = c.String(maxLength: 1), CreatedDate = c.DateTime(nullable: false), LinkedLogin = c.String(maxLength: 60), }) .PrimaryKey(t => t.PersonId); CreateTable( "dbo.PersonPersonType", c => new { PersonPersonTypeId = c.Int(nullable: false, identity: true), PersonId = c.Int(nullable: false), PersonTypeId = c.Int(nullable: false), }) .PrimaryKey(t => t.PersonPersonTypeId) .ForeignKey("dbo.Person", t => t.PersonId, cascadeDelete: true) .ForeignKey("dbo.PersonType", t => t.PersonTypeId, cascadeDelete: true) .Index(t => t.PersonId) .Index(t => t.PersonTypeId); CreateTable( "dbo.PersonType", c => new { PersonTypeId = c.Int(nullable: false, identity: true), Description = c.String(nullable: false, maxLength: 50), }) .PrimaryKey(t => t.PersonTypeId); CreateTable( "dbo.PersonRelationship", c => new { PersonPersonTypeId = c.Int(nullable: false, identity: true), PersonId = c.Int(nullable: false), RelatedPersonId = c.Int(nullable: false), }) .PrimaryKey(t => t.PersonPersonTypeId); CreateTable( "dbo.PracticePerson", c => new { PracticePersonId = c.Int(nullable: false, identity: true), PracticeId = c.Int(nullable: false), PersonPersonTypeId = c.Int(nullable: false), ActiveIndic = c.Boolean(nullable: false), }) .PrimaryKey(t => t.PracticePersonId) .ForeignKey("dbo.PersonPersonType", t => t.PersonPersonTypeId, cascadeDelete: true) .ForeignKey("dbo.Practice", t => t.PracticeId, cascadeDelete: true) .Index(t => t.PracticeId) .Index(t => t.PersonPersonTypeId); } public override void Down() { DropForeignKey("dbo.PracticePerson", "PracticeId", "dbo.Practice"); DropForeignKey("dbo.PracticePerson", "PersonPersonTypeId", "dbo.PersonPersonType"); DropForeignKey("dbo.PersonPersonType", "PersonTypeId", "dbo.PersonType"); DropForeignKey("dbo.PersonPersonType", "PersonId", "dbo.Person"); DropForeignKey("dbo.PersonContact", "PersonId", "dbo.Person"); DropForeignKey("dbo.PersonContact", "ContactTypeId", "dbo.ContactType"); DropForeignKey("dbo.PersonContact", "ContactClassId", "dbo.ContactClass"); DropIndex("dbo.PracticePerson", new[] { "PersonPersonTypeId" }); DropIndex("dbo.PracticePerson", new[] { "PracticeId" }); DropIndex("dbo.PersonPersonType", new[] { "PersonTypeId" }); DropIndex("dbo.PersonPersonType", new[] { "PersonId" }); DropIndex("dbo.PersonContact", new[] { "ContactClassId" }); DropIndex("dbo.PersonContact", new[] { "ContactTypeId" }); DropIndex("dbo.PersonContact", new[] { "PersonId" }); DropTable("dbo.PracticePerson"); DropTable("dbo.PersonRelationship"); DropTable("dbo.PersonType"); DropTable("dbo.PersonPersonType"); DropTable("dbo.Person"); DropTable("dbo.ContactType"); DropTable("dbo.PersonContact"); DropTable("dbo.ContactClass"); } } }