KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a scenario where i would like to change the primary key name in an entity and be able to run update-database -force. See below for code and error getting when i try. Entity was: public class Team { [Key] [HiddenInput(DisplayValue = false)] public virtual int Id { get; set; } [Display(Name = "Full Name:")] public virtual string Name { get; set; } } Entity Changed to: public class Team { [Key] [HiddenInput(DisplayValue = false)] public virtual int TeamId { get; set; } [Display(Name = "Full Name:")] public virtual string Name { get; set; } } When i run Update-database -Force i get the following error. Multiple identity columns specified for table 'Teams'. Only one identity column per table is allowed. Its a matter of naming convention and i need this to be TeamId when i reference it latter, simply Id conflicts with child entity classes. Any ideas on how i can do this successfully?
Tags (comma-separated)
Save Edits
Cancel