Advertisement
Guest User

EF Migration Example

a guest
May 4th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 15.13 KB | None | 0 0
  1. namespace Alman.Data.Migrations
  2. {
  3.     using System;
  4.     using System.Data.Entity.Migrations;
  5.    
  6.     public partial class april20_2015 : DbMigration
  7.     {
  8.         public override void Up()
  9.         {
  10.             CreateTable(
  11.                 "dbo.BloodPressurePosition",
  12.                 c => new
  13.                     {
  14.                         Id = c.Int(nullable: false, identity: true),
  15.                         Name = c.String(),
  16.                         Value = c.String(),
  17.                         Description = c.String(),
  18.                         UserGuidance = c.String(),
  19.                         ExpirationDate = c.DateTime(),
  20.                         SortOrder = c.Int(nullable: false),
  21.                         DataPartitionId = c.Int(nullable: false),
  22.                         LastModified = c.DateTime(nullable: false),
  23.                         ModifiedById = c.Int(nullable: false),
  24.                         IsDeleted = c.Boolean(nullable: false),
  25.                     })
  26.                 .PrimaryKey(t => t.Id)
  27.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  28.                 .Index(t => t.ModifiedById);
  29.            
  30.             CreateTable(
  31.                 "dbo.DiseaseStatus",
  32.                 c => new
  33.                     {
  34.                         Id = c.Int(nullable: false, identity: true),
  35.                         Name = c.String(),
  36.                         Value = c.String(),
  37.                         Description = c.String(),
  38.                         UserGuidance = c.String(),
  39.                         ExpirationDate = c.DateTime(),
  40.                         SortOrder = c.Int(nullable: false),
  41.                         DataPartitionId = c.Int(nullable: false),
  42.                         LastModified = c.DateTime(nullable: false),
  43.                         ModifiedById = c.Int(nullable: false),
  44.                         IsDeleted = c.Boolean(nullable: false),
  45.                     })
  46.                 .PrimaryKey(t => t.Id)
  47.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  48.                 .Index(t => t.ModifiedById);
  49.            
  50.             CreateTable(
  51.                 "dbo.InterestLevel",
  52.                 c => new
  53.                     {
  54.                         Id = c.Int(nullable: false, identity: true),
  55.                         Name = c.String(),
  56.                         Value = c.String(),
  57.                         Description = c.String(),
  58.                         UserGuidance = c.String(),
  59.                         ExpirationDate = c.DateTime(),
  60.                         SortOrder = c.Int(nullable: false),
  61.                         DataPartitionId = c.Int(nullable: false),
  62.                         LastModified = c.DateTime(nullable: false),
  63.                         ModifiedById = c.Int(nullable: false),
  64.                         IsDeleted = c.Boolean(nullable: false),
  65.                     })
  66.                 .PrimaryKey(t => t.Id)
  67.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  68.                 .Index(t => t.ModifiedById);
  69.            
  70.             CreateTable(
  71.                 "dbo.LogEntryType",
  72.                 c => new
  73.                     {
  74.                         Id = c.Int(nullable: false, identity: true),
  75.                         Name = c.String(),
  76.                         Value = c.String(),
  77.                         Description = c.String(),
  78.                         UserGuidance = c.String(),
  79.                         ExpirationDate = c.DateTime(),
  80.                         SortOrder = c.Int(nullable: false),
  81.                         DataPartitionId = c.Int(nullable: false),
  82.                         LastModified = c.DateTime(nullable: false),
  83.                         ModifiedById = c.Int(nullable: false),
  84.                         IsDeleted = c.Boolean(nullable: false),
  85.                     })
  86.                 .PrimaryKey(t => t.Id)
  87.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  88.                 .Index(t => t.ModifiedById);
  89.            
  90.             CreateTable(
  91.                 "dbo.OxygenIntakeMethod",
  92.                 c => new
  93.                     {
  94.                         Id = c.Int(nullable: false, identity: true),
  95.                         Name = c.String(),
  96.                         Value = c.String(),
  97.                         Description = c.String(),
  98.                         UserGuidance = c.String(),
  99.                         ExpirationDate = c.DateTime(),
  100.                         SortOrder = c.Int(nullable: false),
  101.                         DataPartitionId = c.Int(nullable: false),
  102.                         LastModified = c.DateTime(nullable: false),
  103.                         ModifiedById = c.Int(nullable: false),
  104.                         IsDeleted = c.Boolean(nullable: false),
  105.                     })
  106.                 .PrimaryKey(t => t.Id)
  107.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  108.                 .Index(t => t.ModifiedById);
  109.            
  110.             CreateTable(
  111.                 "dbo.OxygenLPM",
  112.                 c => new
  113.                     {
  114.                         Id = c.Int(nullable: false, identity: true),
  115.                         Name = c.String(),
  116.                         Value = c.String(),
  117.                         Description = c.String(),
  118.                         UserGuidance = c.String(),
  119.                         ExpirationDate = c.DateTime(),
  120.                         SortOrder = c.Int(nullable: false),
  121.                         DataPartitionId = c.Int(nullable: false),
  122.                         LastModified = c.DateTime(nullable: false),
  123.                         ModifiedById = c.Int(nullable: false),
  124.                         IsDeleted = c.Boolean(nullable: false),
  125.                     })
  126.                 .PrimaryKey(t => t.Id)
  127.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  128.                 .Index(t => t.ModifiedById);
  129.            
  130.             CreateTable(
  131.                 "dbo.RecreationInterestType",
  132.                 c => new
  133.                     {
  134.                         Id = c.Int(nullable: false, identity: true),
  135.                         Name = c.String(),
  136.                         Value = c.String(),
  137.                         Description = c.String(),
  138.                         UserGuidance = c.String(),
  139.                         ExpirationDate = c.DateTime(),
  140.                         SortOrder = c.Int(nullable: false),
  141.                         DataPartitionId = c.Int(nullable: false),
  142.                         LastModified = c.DateTime(nullable: false),
  143.                         ModifiedById = c.Int(nullable: false),
  144.                         IsDeleted = c.Boolean(nullable: false),
  145.                     })
  146.                 .PrimaryKey(t => t.Id)
  147.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  148.                 .Index(t => t.ModifiedById);
  149.            
  150.             CreateTable(
  151.                 "dbo.RiskAgreement",
  152.                 c => new
  153.                     {
  154.                         Id = c.Int(nullable: false, identity: true),
  155.                         Name = c.String(),
  156.                         Value = c.String(),
  157.                         Description = c.String(),
  158.                         UserGuidance = c.String(),
  159.                         ExpirationDate = c.DateTime(),
  160.                         SortOrder = c.Int(nullable: false),
  161.                         DataPartitionId = c.Int(nullable: false),
  162.                         LastModified = c.DateTime(nullable: false),
  163.                         ModifiedById = c.Int(nullable: false),
  164.                         IsDeleted = c.Boolean(nullable: false),
  165.                     })
  166.                 .PrimaryKey(t => t.Id)
  167.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  168.                 .Index(t => t.ModifiedById);
  169.            
  170.             CreateTable(
  171.                 "dbo.RiskLevel",
  172.                 c => new
  173.                     {
  174.                         Id = c.Int(nullable: false, identity: true),
  175.                         Name = c.String(),
  176.                         Value = c.String(),
  177.                         Description = c.String(),
  178.                         UserGuidance = c.String(),
  179.                         ExpirationDate = c.DateTime(),
  180.                         SortOrder = c.Int(nullable: false),
  181.                         DataPartitionId = c.Int(nullable: false),
  182.                         LastModified = c.DateTime(nullable: false),
  183.                         ModifiedById = c.Int(nullable: false),
  184.                         IsDeleted = c.Boolean(nullable: false),
  185.                     })
  186.                 .PrimaryKey(t => t.Id)
  187.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  188.                 .Index(t => t.ModifiedById);
  189.            
  190.             CreateTable(
  191.                 "dbo.SafetyConcern",
  192.                 c => new
  193.                     {
  194.                         Id = c.Int(nullable: false, identity: true),
  195.                         Name = c.String(),
  196.                         Value = c.String(),
  197.                         Description = c.String(),
  198.                         UserGuidance = c.String(),
  199.                         ExpirationDate = c.DateTime(),
  200.                         SortOrder = c.Int(nullable: false),
  201.                         DataPartitionId = c.Int(nullable: false),
  202.                         LastModified = c.DateTime(nullable: false),
  203.                         ModifiedById = c.Int(nullable: false),
  204.                         IsDeleted = c.Boolean(nullable: false),
  205.                     })
  206.                 .PrimaryKey(t => t.Id)
  207.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  208.                 .Index(t => t.ModifiedById);
  209.            
  210.             CreateTable(
  211.                 "dbo.TemperatureLocation",
  212.                 c => new
  213.                     {
  214.                         Id = c.Int(nullable: false, identity: true),
  215.                         Name = c.String(),
  216.                         Value = c.String(),
  217.                         Description = c.String(),
  218.                         UserGuidance = c.String(),
  219.                         ExpirationDate = c.DateTime(),
  220.                         SortOrder = c.Int(nullable: false),
  221.                         DataPartitionId = c.Int(nullable: false),
  222.                         LastModified = c.DateTime(nullable: false),
  223.                         ModifiedById = c.Int(nullable: false),
  224.                         IsDeleted = c.Boolean(nullable: false),
  225.                     })
  226.                 .PrimaryKey(t => t.Id)
  227.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  228.                 .Index(t => t.ModifiedById);
  229.            
  230.             CreateTable(
  231.                 "dbo.TenantContactRelationship",
  232.                 c => new
  233.                     {
  234.                         Id = c.Int(nullable: false, identity: true),
  235.                         Name = c.String(),
  236.                         Value = c.String(),
  237.                         Description = c.String(),
  238.                         UserGuidance = c.String(),
  239.                         ExpirationDate = c.DateTime(),
  240.                         SortOrder = c.Int(nullable: false),
  241.                         DataPartitionId = c.Int(nullable: false),
  242.                         LastModified = c.DateTime(nullable: false),
  243.                         ModifiedById = c.Int(nullable: false),
  244.                         IsDeleted = c.Boolean(nullable: false),
  245.                     })
  246.                 .PrimaryKey(t => t.Id)
  247.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  248.                 .Index(t => t.ModifiedById);
  249.            
  250.             CreateTable(
  251.                 "dbo.TenantContactType",
  252.                 c => new
  253.                     {
  254.                         Id = c.Int(nullable: false, identity: true),
  255.                         Name = c.String(),
  256.                         Value = c.String(),
  257.                         Description = c.String(),
  258.                         UserGuidance = c.String(),
  259.                         ExpirationDate = c.DateTime(),
  260.                         SortOrder = c.Int(nullable: false),
  261.                         DataPartitionId = c.Int(nullable: false),
  262.                         LastModified = c.DateTime(nullable: false),
  263.                         ModifiedById = c.Int(nullable: false),
  264.                         IsDeleted = c.Boolean(nullable: false),
  265.                     })
  266.                 .PrimaryKey(t => t.Id)
  267.                 .ForeignKey("dbo.User", t => t.ModifiedById, cascadeDelete: true)
  268.                 .Index(t => t.ModifiedById);
  269.            
  270.         }
  271.        
  272.         public override void Down()
  273.         {
  274.             DropForeignKey("dbo.TenantContactType", "ModifiedById", "dbo.User");
  275.             DropForeignKey("dbo.TenantContactRelationship", "ModifiedById", "dbo.User");
  276.             DropForeignKey("dbo.TemperatureLocation", "ModifiedById", "dbo.User");
  277.             DropForeignKey("dbo.SafetyConcern", "ModifiedById", "dbo.User");
  278.             DropForeignKey("dbo.RiskLevel", "ModifiedById", "dbo.User");
  279.             DropForeignKey("dbo.RiskAgreement", "ModifiedById", "dbo.User");
  280.             DropForeignKey("dbo.RecreationInterestType", "ModifiedById", "dbo.User");
  281.             DropForeignKey("dbo.OxygenLPM", "ModifiedById", "dbo.User");
  282.             DropForeignKey("dbo.OxygenIntakeMethod", "ModifiedById", "dbo.User");
  283.             DropForeignKey("dbo.LogEntryType", "ModifiedById", "dbo.User");
  284.             DropForeignKey("dbo.InterestLevel", "ModifiedById", "dbo.User");
  285.             DropForeignKey("dbo.DiseaseStatus", "ModifiedById", "dbo.User");
  286.             DropForeignKey("dbo.BloodPressurePosition", "ModifiedById", "dbo.User");
  287.             DropIndex("dbo.TenantContactType", new[] { "ModifiedById" });
  288.             DropIndex("dbo.TenantContactRelationship", new[] { "ModifiedById" });
  289.             DropIndex("dbo.TemperatureLocation", new[] { "ModifiedById" });
  290.             DropIndex("dbo.SafetyConcern", new[] { "ModifiedById" });
  291.             DropIndex("dbo.RiskLevel", new[] { "ModifiedById" });
  292.             DropIndex("dbo.RiskAgreement", new[] { "ModifiedById" });
  293.             DropIndex("dbo.RecreationInterestType", new[] { "ModifiedById" });
  294.             DropIndex("dbo.OxygenLPM", new[] { "ModifiedById" });
  295.             DropIndex("dbo.OxygenIntakeMethod", new[] { "ModifiedById" });
  296.             DropIndex("dbo.LogEntryType", new[] { "ModifiedById" });
  297.             DropIndex("dbo.InterestLevel", new[] { "ModifiedById" });
  298.             DropIndex("dbo.DiseaseStatus", new[] { "ModifiedById" });
  299.             DropIndex("dbo.BloodPressurePosition", new[] { "ModifiedById" });
  300.             DropTable("dbo.TenantContactType");
  301.             DropTable("dbo.TenantContactRelationship");
  302.             DropTable("dbo.TemperatureLocation");
  303.             DropTable("dbo.SafetyConcern");
  304.             DropTable("dbo.RiskLevel");
  305.             DropTable("dbo.RiskAgreement");
  306.             DropTable("dbo.RecreationInterestType");
  307.             DropTable("dbo.OxygenLPM");
  308.             DropTable("dbo.OxygenIntakeMethod");
  309.             DropTable("dbo.LogEntryType");
  310.             DropTable("dbo.InterestLevel");
  311.             DropTable("dbo.DiseaseStatus");
  312.             DropTable("dbo.BloodPressurePosition");
  313.         }
  314.     }
  315. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement