All of my entities have a base class:
public class Entity<TKey> : IEntity<TKey>
{
dynamic IEntity.Id
{
get
{
return this.Id;
}
set
{
this.Id = value;
}
}
public TKey Id { get; set; }
}
For example Status entity:
[MetadataType(typeof(StatusMetadata))]
public partial class Status : Entity<byte>
{
public string Title { get; set; }
}
When I run the query against the database I get the following error: "The item with identity 'Id' already exists in the metadata collection. Parameter name: item". Is there any way to fix this or it's an issue caused by inheritance and I can't inherit my entities from any class?
It seems a generic error, searching for some insights, I saw that:
Two tables can have the same name for a primary key. Look at the LightSwitch tables, they all have a primary key called Id.
At http://social.msdn.microsoft.com/Forums/vstudio/en-US/bd8d47da-d1b4-4be8-a7e5-193fb5360060/the-item-with-identity-actionpk-already-exists-in-the-metadata-collection?forum=lightswitch
So, I review all entities and I get an entity with a Identiy data type changed and a inherit another class it has int Id property.
Do I change this public new string Id { get; set; }
to public string Id { get; set; }
like others and remove the inherit and everything works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With