Postgresql oid column attribute type with EF6

Asked

Viewed 161 times

0

What type of attribute should I use to represent a type column oid of Postgresql with Entity Framework 6 Code-First?

Remembering that the type oid Postgresql is for storing files.

2 answers

2

According to the Npgsql provider documentation (I imagine this is the one you’re using) the type is the uint. Since there is no EF support for unmarked types, then use the int same. Or change ORM :P

1


  • Sorry to resume the question, but new questions have arisen. I don’t understand what this persistence will be like. Let’s say I have a class called Cliente three-property, Id, Nome, Foto, where according to what was explained, Foto must be the type int. Assuming in this case that the photo has been captured and is in a temporary directory. My reasoning has ended here. How would I tell EF to take the file that is in the directory and write to the bank? And what is the role of the property int Foto?

  • @Matheussaraiva depends on your business rule, In my case I keep the photo in a directory and in the database only the path of the photo. You can also save the byte array of the photo in your table, but, you will overload the system, slowing down. To record photos for example in Sqlserver has image or varbinary(Max) I believe that in postgresql is bytea ... I hope to have helped ... If you are going to recommend to write the file on disk the access is faster ... and more practical

  • I understand, but OID also serves to store files in the database, actually OID is more indicated than bytea, has better performance and supports larger files. But not yet figured out how to persist the file with Entity Framework.

  • @Matheussaraiva when I have doubts I do the reverse engineering I take what has table in the bank and have generated the classes to know what type of data fits. Try this with Entityframework Reverse Poco Codefirst Generator https://visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838/view/Reviews/2. as I do not have this database installed and have never used this particular question, I apologize

  • 1

    As some friends of mine would say, "Only not...". Unfortunately the support for Postgresql in EF is still very limited. In the search for the solution I ended up discovering that EF does not allow code-first with Postgresql. So the tables should be created by hand. Ai not right, if it is to be so better to lower the level and put your hand in the ado.net direct.

  • @Matheussaraiva I know that in Entity Core this has already been solved, in 6.1.3 has these drawbacks

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.