0

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.

5
  • tallmaris.com/… will show you how to do the relationship. What error are you getting for the Byte[]? Commented May 23, 2014 at 19:35
  • it says syntax error; value expected Commented May 23, 2014 at 20:01
  • use c.Binary() instead of c.Byte[] Commented May 23, 2014 at 20:10
  • ok and also tell me about the relationship between two tables. How do I mention that in migrations ? Also I want to create a relationship between existing membership tables with my new tables... Commented May 23, 2014 at 20:20
  • There's an example in the link in my first post. I added the key line to an answer below with the note about Byte[] as well. Commented May 23, 2014 at 20:25

1 Answer 1

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.