Basically I have a Client
class and an Address
class like the following
public class Client
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Description{ get; set; }
public string Email { get; set; }
public string Website { get; set; }
public string PhoneNumber { get; set; }
[ForeignKey(typeof(Address))]
public int AddressId { get; set;}
[OneToOne(CascadeOperations = CascadeOperation.All)]
public Address Address { get; set; }
}
public class Address
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Line1 {get;set;}
public string Line2 {get;set;}
public string Line3 {get;set;}
public string Line4 {get;set;}
public string Line5 {get;set;}
public string Line6 {get;set;}
}
I'm using the nuget package SQLite.Net-PCL coupled with the SQLite.Net-PCL Extensions so that I can basically call Insert and pass the Client
object to save a client, complete with their address, to the database. Like this:
_db.InsertWithChildren(clientObject);
In my application (Xamarin.iOS with MvvmCross) I have bundled a preexisting database with the application so hence I do not create the tables in code so my point of failure is on the InsertWithChildren(clientObject)
call.
I've tried removing the preexisting tables and then creating the tables in code, Address
table first and then Client
but on create of the Client table it tells me that it "doesn't know" about the Address
type/property. The same error if you try the Client
table first. I've tried as many variations of this as possible to just save the Client with the Address in a single call but to no avail.
Can anyone shed some light on this?