I got a mapping that maps IPAddress
object field to database.
There is inet
type in PostgreSQL suited for this, but in my case it uses bytea
type instead when it generates schema.
Is there a way to force resulting generated schema type for this column to be inet
actually in DB?
I also happen to have this requirement on composite ID (whicg is required)
CompositeId()
.KeyProperty(x => x.Date, "for_date")
.KeyProperty(x => x.Address, var => var.ColumnName("ipaddress"));
You cant really use CustomSqlType on key property part.
I also tried using
public class IPAddressPropertyConvention : IPropertyConvention
{
public void Apply(IPropertyInstance instance)
{
if (instance.Property.PropertyType == typeof(IPAddress))
instance.CustomSqlType("inet");
}
}
But I get exception about invalid property convention
Map(x => x.IPAddress)
.CustomSqlType("inet")
.CustomType<IPAddressToInetUserType>(); // maybe needed, you should check
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With