question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blob issue with entity framework 5

See original GitHub issue

I am getting this exception upon initial entity framework migration of my postgres db:

Error Exception: Npgsql.PostgresException (0x80004005): 42704: type "blob" does not exist
   at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult()
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteNonQuery()

Here is my create script:

table.Column<byte[]>(maxLength: 16, nullable: false),
b.Property<byte[]>("BytesColumn")
      .IsRequired()
      .HasColumnType("BLOB")
      .HasMaxLength(16);

Is there nothing that changes blob to bytea?

Changing the “BLOB” entries to “bytea” does not fix the issue.

Using latest version of the nuget as os 2021-03-16.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Mar 17, 2021

@jjxtra data types simply aren’t the same across database; it’s not just a question of blob vs. bytea - SQL Server has nvarchar whereas PostgreSQL has text. It doesn’t make any sense to make the PostgreSQL migrations provider recognize all data types of all other database…

Note also that there are various other differences between databases - not just data type names - which also affect migrations. So this approach wouldn’t work in the general case.

Please take a look at the docs I linked to above on managing migrations and multiple databases. You typically need to generate each migration for your different supported databases.

0reactions
jjxtracommented, Apr 8, 2021

I am changing blob to bytea so that I don’t have to maintain a sqlite and postgres migration, as I mentioned earlier, every other sqlite datatype is compatible with postgres, so having this one line of code added would be nice, even if it’s not officially postgres standard. All my tests use sqlite, and production servers use postgres.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Framework Core traverse big blob data without ...
I'm writing code that's traversing big amounts of picture data, preparing a big delta block containing it all compressed for sending. Here's a ......
Read more >
Performance considerations for EF4, EF5, and EF6
2 Performance issues when the object cache has many entities. The object cache helps to increase the overall responsiveness of Entity Framework.
Read more >
7.1 Entity Framework 6 Support
MySQL Connector/NET integrates support for Entity Framework 6 (EF6), which now includes support for cross-platform application deployment with the EF 6.4 ...
Read more >
Using Large Character or Binary Data Types
This annotation will force a BLOB column to be created. [Column("BLOB_COLUMN", TypeName = "BLOB")] public byte[] BYTE_TYPE { get; set; }.
Read more >
ASP.NET Core – Azure Blob Storage – Repository Pattern
The purpose of this document is to describe the steps necessary to create a development environment for using Azure Blob Storage using the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found