user3532152
user3532152

Reputation: 17

Creating table in migration InitialCreate.cs

I am trying to create a table inside up function.

public override void Up()
    {
        CreateTable(
            "dbo.CrimeReort",
            c => new
                {
                    ImageId = c.Int(nullable: false, identity: true),
                    ImageName = c.String(nullable: false),
                    ImageContent = c.Byte[](nullable: false),
                    Createdby=c.String(),
                    CreatedDt=c.DateTime(),
                    Updatedby =c.String(),
                    UpdatedDt=c.DateTime(),
                    flag = c.Boolean(nullable: false),
                })
            .PrimaryKey(t => t.ImageId);

    }

I want to declare a byte array byte[] but its giving me an error. Besides that this table has a one-one relationship with another table .I also need to cater that as well. I do not know how to make that relationship in migrations.

Upvotes: 0

Views: 162

Answers (1)

RyanB
RyanB

Reputation: 757

AddForeignKey("dbo.CrimeReport", "foreign_Id", "dbo.ForeignTable", "Id");

Also use c.Binary() instead of c.Byte[]

Upvotes: 1

Related Questions