Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class NotesAndTags : DbMigration
- {
- public override void Up()
- {
- CreateTable(
- "dbo.Notes",
- c => new
- {
- ID = c.Int(nullable: false, identity: true),
- Content = c.String(),
- DateOfPosting = c.DateTime(nullable: false),
- OwnerName = c.String(),
- })
- .PrimaryKey(t => t.ID);
- CreateTable(
- "dbo.Tags",
- c => new
- {
- ID = c.Int(nullable: false, identity: true),
- Name = c.String(),
- })
- .PrimaryKey(t => t.ID);
- CreateTable(
- "dbo.TagsNotes",
- c => new
- {
- Tags_ID = c.Int(nullable: false),
- Notes_ID = c.Int(nullable: false),
- })
- .PrimaryKey(t => new { t.Tags_ID, t.Notes_ID })
- .ForeignKey("dbo.Tags", t => t.Tags_ID, cascadeDelete: true)
- .ForeignKey("dbo.Notes", t => t.Notes_ID, cascadeDelete: true)
- .Index(t => t.Tags_ID)
- .Index(t => t.Notes_ID);
- }
- public override void Down()
- {
- DropForeignKey("dbo.TagsNotes", "Notes_ID", "dbo.Notes");
- DropForeignKey("dbo.TagsNotes", "Tags_ID", "dbo.Tags");
- DropIndex("dbo.TagsNotes", new[] { "Notes_ID" });
- DropIndex("dbo.TagsNotes", new[] { "Tags_ID" });
- DropTable("dbo.TagsNotes");
- DropTable("dbo.Tags");
- DropTable("dbo.Notes");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement