public override void Up()
{
CreateTable(
"dbo.Books",
c => new
{
BookId = c.Int(nullable: false, identity: true),
Title = c.String(nullable: false, maxLength: 255),
Author = c.String(nullable: false, maxLength: 255),
ReleaseDate = c.DateTime(nullable: false),
Description = c.String(nullable: false),
Cost = c.Int(nullable: false),
ImagePath = c.String(),
})
.PrimaryKey(t => t.BookId);
CreateTable(
"dbo.Genres",
c => new
{
GenreId = c.Int(nullable: false, identity: true),
Name = c.String(nullable: false, maxLength: 20),
})
.PrimaryKey(t => t.GenreId);
CreateTable(
"dbo.Roles",
c => new
{
RoleId = c.Int(nullable: false, identity: true),
RoleName = c.String(nullable: false),
Decription = c.String(),
})
.PrimaryKey(t => t.RoleId);
CreateTable(
"dbo.Users",
c => new
{
UserId = c.Int(nullable: false, identity: true),
Username = c.String(nullable: false),
Email = c.String(nullable: false),
Password = c.String(nullable: false),
FirstName = c.String(),
LastName = c.String(),
IsActived = c.Boolean(nullable: false),
CreateDate = c.DateTime(nullable: false),
})
.PrimaryKey(t => t.UserId);
CreateTable(
"dbo.BookGenres",
c => new
{
BookId = c.Int(nullable: false),
GenreId = c.Int(nullable: false),
})
.PrimaryKey(t => new { t.BookId, t.GenreId })
.ForeignKey("dbo.Books", t => t.BookId, cascadeDelete: true)
.ForeignKey("dbo.Genres", t => t.GenreId, cascadeDelete: true)
.Index(t => t.BookId)
.Index(t => t.GenreId);
CreateTable(
"dbo.UserRoles",
c => new
{
UserId = c.Int(nullable: false),
RoleId = c.Int(nullable: false),
})
.PrimaryKey(t => new { t.UserId, t.RoleId })
.ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true)
.ForeignKey("dbo.Roles", t => t.RoleId, cascadeDelete: true)
.Index(t => t.UserId)
.Index(t => t.RoleId);
}