Entity Framework, Code First, NpgsqlInterval

135 views
Skip to first unread message

nulla.e...@web.de

unread,
Mar 4, 2015, 9:30:24 AM3/4/15
to npgsq...@googlegroups.com
How can I use NpgsqlInterval in Entity Framework 6.1, Code First?

With this code I get a System.InvalidOperationException as soon as my program tries to access an instance of class "Feldtest":

public class Feldtest
{
public int FID { get; set; }
... other properties
public NpgsqlInterval Abstand { get; set; }
}

Exception:

System.InvalidOperationException wurde nicht behandelt.
HResult=-2146233079
Message=The property 'Abstand' is not a declared property on type 'Feldtest'. Verify that the property has not been explicitly excluded from the model by using the Ignore method or NotMappedAttribute data annotation. Make sure that it is a valid primitive property.
Source=EntityFramework
...

I can't use a TimeSpan property, because it falsifies the data (30 days instead of 1 month, 360 days instead of 1 year etc.). I could quite well use the string representation, but I don't know how to write my class to do that.

Thank you for help!

Emil Lenngren

unread,
Mar 4, 2015, 5:13:06 PM3/4/15
to nulla.e...@web.de, npgsq...@googlegroups.com
Using non-standard data types in Entity Framework is a bit problematic since it only supports the types MS has decided should be supported.
To declare a field as a string type might also be problematic since then it assumes the postgresql data type is Text so you might get sql conversion errors... But you could try it I think.



--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/npgsql-help/a824bc1c-7d9d-46d2-8e3d-f5f64d7358bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages