yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.9k stars 1.06k forks source link

[New Feature] Implement a C# smart client for the most popular ORM - Entity Framework Core #20511

Closed someonestolemyusername closed 2 months ago

someonestolemyusername commented 8 months ago

Description

It is preferable for applications to use smart clients. There is an existing supported smart client for C# which is based on Npgsql - see #10826.

However, many existing and new .NET applications use Entity Framework Core to access the database.

For vanilla postgres, there is an existing adapter for Postgres called Npgsql.EntityFrameworkCore.PostgreSQL. However, if you attempt to pass a Yugabyte-aware connection to this adapter, you get an error such as:

System.InvalidCastException: Unable to cast object of type 'YBNpgsql.NpgsqlConnection' to type 'Npgsql.NpgsqlConnection'.
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlRelationalConnection.get_DbConnection()
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlRelationalConnection.CloneWith(String connectionString)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists(Boolean async, CancellationToken cancellationToken)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists()

It would be awesome (in my opinion) if an Entity Framework Core adapter could be provided for Yugabyte - I think it would just require forking the existing Npgsql provider and changing it to reference the smart client.

Thanks :)

Warning: Please confirm that this issue does not contain any sensitive information

Sfurti-yb commented 5 months ago

@someonestolemyusername Sorry for the delay, we will look into this ASAP and keep you updated. Thanks!

Sfurti-yb commented 5 months ago

For Entity Framework support we will need to upgrade the driver to the latest version and publish our adaptor. We will pick up this work in a couple of months time.

ddorian commented 2 months ago

Added in https://www.nuget.org/packages/NpgsqlYB.EntityFrameworkCore.YugabyteDB/8.0.4-yb-1-preview