-
|
I have a table on Supabase with 3 columns:
Then in my class [Table("transaction_tags")]
internal sealed class DbTransactionTag : BaseModel
{
[PrimaryKey("transaction_id")]
public Guid TransactionId { get; set; }
[PrimaryKey("tag_id")]
public Guid TagId { get; set; }
[Column("user_id")]
public Guid UserId { get; set; }
}And then I try to insert it var dbTag = new DbTransactionTag
{
TagId = tag.Id,
TransactionId = transaction.Id, // This is 100% not null, I've checked multiple scenarios with the debugger
UserId = UserId
};
await supabase.From<DbTransactionTag>().Insert(dbTag, minimalQueryOptions, cancellationToken);But no matter what, I just get Am I missing something obvious here? I'm clearly setting the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I managed to solve it by changing So my class would be [Table("transaction_tags")]
internal sealed class DbTransactionTag : BaseModel
{
- [PrimaryKey("transaction_id")]
+ [PrimaryKey("transaction_id", true)]
public Guid TransactionId { get; set; }
- [PrimaryKey("tag_id")]
+ [PrimaryKey("tag_id", true)]
public Guid TagId { get; set; }
[Column("user_id")]
public Guid UserId { get; set; }
} |
Beta Was this translation helpful? Give feedback.
I managed to solve it by changing
PrimaryKey("")toPrimaryKey("", true). There's a hiddenshouldInsertparameter there that should be true.So my class would be
[Table("transaction_tags")] internal sealed class DbTransactionTag : BaseModel { - [PrimaryKey("transaction_id")] + [PrimaryKey("transaction_id", true)] public Guid TransactionId { get; set; } - [PrimaryKey("tag_id")] + [PrimaryKey("tag_id", true)] public Guid TagId { get; set; } [Column("user_id")] public Guid UserId { get; set; } }