0

I've just updated all the SQLite nugget packages in my proj. All db operations were working just fine.

Now, when I try this: items = db.GetAllWithChildren();

I get this error: Item.ItemEvents: OneToMany relationship origin must have Primary Key

So nothing has changed in code and primary keys are GUIDs as strings All entities inherit from a base class like this:

    public class BusinessEntityBase : IBusinessEntity
{
    public BusinessEntityBase()
    {
        Id = Guid.NewGuid().ToString();
    }

    [PrimaryKey]
    public string Id { get; set; }
}

Does that error mean that I cannot/should not inherit from a base class which implements the Id property? Should each class implement it's own Id property?

I'm only asking as all these attributes/relationships are sorted out through reflection and something might have changed to negate how I've built my entity layer...

Not sure why I'm getting this now and not before updating all SQLite plugins...

Thx SQLite Packages Installed

Lindsay
  • 41
  • 8
  • Can you verify that you only have one SQLite-Net Extensions package and only one sqlite-net library in your project? – redent84 Mar 12 '18 at 09:14
  • Actually, there is sqlite-net-plc AND SQLite.Net-PLC. I have attempted to remove the first and it won't as there are dependencies and the second is needed for connection-platform definition and instantiation. I'll try post some code in a bit to show what I mean. – Lindsay Mar 13 '18 at 14:29

1 Answers1

0

Found the issue for anyone who needs to know.

Entity attributes are ambiguous across the SQLite and SQLite.Net.Attributes namespaces.

The attributes need to be prefixed with the SQLite namespace, ie: [SQLite.PrimaryKey]

Hope that helps a few...

Lindsay
  • 41
  • 8