_From @eBerdnA on December 29, 2015 15:53_
I just noticed that scaffolding a table which includes a column with datatype bytea[] can't be scaffolded. The following warning is generated.
Could not find type mapping for column 'public.File.md5Hash' with data type '_bytea'. Skipping column.
Unable to scaffold the index 'File_md5Hash_key' because one of the properties it contains could not be scaffolded.
I'm using a simple table like this.
CREATE TABLE "File"
(
"FileId" serial NOT NULL,
"Filename" character varying(255) NOT NULL,
"md5Hash" bytea[] NOT NULL,
CONSTRAINT "File_pkey" PRIMARY KEY ("FileId"),
CONSTRAINT "File_md5Hash_key" UNIQUE ("md5Hash")
)
WITH (
OIDS=FALSE
);
ALTER TABLE "File"
OWNER TO postgres;
Does this happen due to a limitation of the EntityFramework or due to an issue of npgsql?
_Copied from original issue: npgsql/npgsql#926_
This should definitely be supported, I'll take a look.
This is actually a wider problem I ran into a while ago - how should array types be handled. In general, EF7 treats such properties as navigation properties; we need to check what happens if an entity has an array property (or more generally an IList property) over a type that isn't itself an entity. If these are simply ignored by the EF7 core then we can probably map these to PostgreSQL arrays.
Either way we need to look at how EF7 normally handles this before tackling reverse engineering.
Is this feature supported now ? I tried just now but still got an error :
{"The property 'Merchandise.PictureUris' could not be mapped, because it is of type 'String[]' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it."}
The 'PictureUris' is a column,of which the datatype is text[].
Nope, still not supported, there were more important things to do. I hope to take a look soon.
I've committed support for arrays, I can see tables being created with int[] and can read and write.
Still left:
Thank you for doing this great job,I tried and it takes effect. My English is very poor, so I’d like to express my gratitude with Chinese —— 谢谢!
@tuoxieyz thanks for the kinds words :)
The feature isn't completely done yet, but the basics are there. Please test and let me know of any issues!
I'm still not able to insert with text arrays using the latest 1.0.2 off nuget.org. I've tried using string[], List
As the milestone shows, this has only been done for the 1.1.0 release, not 1.0.2. 1.1.0 is scheduled for release in November. Until then, if you're brave you can try the 1.1.0 CI nuggets from the Npgsql unstable feed.
I just pulled it in and it appears to be working. I'll use that until November. Thanks for the response.
Great to know it works for you, please let me know if you encounter any issues.
Hello everyone. I'm trying to map a byte field [] to store an image, however I'm getting the error:
Microsoft.EntityFrameworkCore.Infrastructure [10403]
Entity Framework Core 2.1.1-rtm-30846 initialized 'TeAjudoContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL' with options: None
System.InvalidOperationException: No mapping to a relational type can be found for property 'prjTeAjudoCore.Models.EstabelecimentoCredito.ProvanteTransfer' with the CLR type 'Nullable
My Field:
[Column("ESCR_BT_COMPROVANTE", TypeName = "bytea")]
[DisplayName("Comprovante de Transferência")]
public byte[] ComprovanteTransferencia { get; set; }
can you help me?
Most helpful comment
Thank you for doing this great job,I tried and it takes effect. My English is very poor, so I’d like to express my gratitude with Chinese —— 谢谢!