I’m creating a database and I want to use a different naming convention other than ‘Id’ for the Id of the table. For example, I have a products table and I want to use ProductId as the primary key name. How do I do this?
When I’m generating my database from my POCO, i get the error ‘Could not find key member ‘Id’ of key ‘Id’ on type ‘myEntity’. The key may be wrong or the field or property on ‘myEntity’ has changed names.
Here’s my entity:
public class Product
{
[Column(IsPrimaryKey=true, IsDbGenerated=true, AutoSync=AutoSync.OnInsert, Name="ProductId")]
internal int ProductId{ get; set; }
[Column (CanBeNull=false)]
public string Name { get; set; }
[Column (CanBeNull=false)]
public DateTime CreatedDate { get; set; }
[Column (CanBeNull=true)]
public DateTime? ModifiedDate { get; set; }
}
Is Products the only table referenced from your DataContext? This works for me: