I have an Entity Framework Code First MVC3 solution where I have an entity named Settings where I only have 1 record in it. This entity is used to store general settings for the solution.
public class Settings
{
public bool CommunicationActivated { get; set; }
public string CommunicationMessage { get; set; }
...
}
When I run the solution, I got the error: System.Data.Edm.EdmEntityType: : EntityType ‘Settings’ has no key defined. Define the key for this EntityType.
My question: is it possible to have an entity without key defined? Is it a good idea for an entity with only one record?
Thanks.
I recommend that you just add a new column:
This does no harm and allows you to work with the tools, not against them.
You can even ensure that the table only has one record: Set the
IDfield manually to1and add a check constraint for(ID = 1).