Friday, 9 August 2013

Remove primary key in entity framework table field in mvc4

Remove primary key in entity framework table field in mvc4

I have created a model in the name of Sample with an Id and DocumentId
property.In this I don't mention primary key for Id property.But it forms
the primary key when I created the Sample as table in entity framework.I
want to remove the primary key for Id. What do I have to do. Please help
me. I am very new to mvc4.
public class Sample
{
[Required,DatabaseGenerated(DatabaseGeneratedOption.None)]
public int Id { get; set; }
[Required]
public int DocumentId { get; set; }
}
public override void Up()
{
CreateTable(
"dbo.Samples",
c => new
{
Id = c.Int(nullable: false, identity: false),
DocumentId = c.Int(nullable: false),
})
.PrimaryKey(t => t.Id);
}

No comments:

Post a Comment