Reputation: 797
I am using ServiceStack v4.x VS2013
By default ServiceStack ORMLite (SqlServer) defines foreign keys with "NOT NULL". The following code produces a foreign key "FooId (FK, long, not null)" How can I tell ServiceStack this foreign key may be null?
public class Blah
{
[AutoIncrement]
public long Id { get; set; }
public string Name { get; set; }
[References(typeof(Foo))]
public long FooId { get; set; }
}
public class Foo
{
[AutoIncrement]
public long Id { get; set; }
public string Description { get; set; }
}
Upvotes: 0
Views: 425
Reputation: 143374
To specify a value type is nullable in OrmLite, make it nullable in C#:
public class Blah
{
[AutoIncrement]
public long Id { get; set; }
public string Name { get; set; }
[References(typeof(Foo))]
public long? FooId { get; set; }
}
Upvotes: 1