Reputation: 1
I'm getting this error message:
"Can't decide which property to consider the Key - you can create one called 'ID' or mark one with SubSonicPrimaryKey attribute"
The code in question is generated by the context.tt
:
public SqlQuery Delete<T>(Expression<Func<T,bool>> column) where T:new()
{
LambdaExpression lamda = column;
SqlQuery result = new Delete<T>(this.Provider);
result = result.From<T>();
result.Constraints=lamda.ParseConstraints().ToList();
return result;
}
In my DB the respective table actually has a primary key called ID
. And I tried to insert the SubSonicPrimaryKey
Attribute:
uint _ID;
[SubSonicPrimaryKey]
public uint ID
{
get { return _ID; }
set
{...
How can I fix this?
Upvotes: 0
Views: 704
Reputation: 6898
My guess is that your issue is related to the uint value type. SubSonic has is problems handling unsigned value types. Try using a int property instead for your primary key!
Upvotes: 0
Reputation: 31743
You should post the stack trace of your exception.
This is just a wild guess but I suppose subsonic finds two possible primary keys, the one called ID and one with the SubSonicPrimaryKey
attribute and does not check wether they are equal and since the count of the possible keys is not equal to 1 the exception is thrown.
You should try to remove the SubSonicPrimaryKey
attribute of your class, since the Property is already called ID
.
Upvotes: 1