Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dotnet core 3.1 version of RelationalMetadataExtensions.Relations()

We are reading relational database specific metadata using RelationalMetadataExtensions in dotnet core 2.0. We have planned to upgrade the app into 3.0. But RelationalMetadataExtensions is obsolute in the dotnet core 3.0. What will be the dotnet core 3.1 behavior of the following code

  // Following code only working for mysql.
        var items = _context.Model.GetEntityTypes();
        foreach (var item in items)
        {
            //RelationalMetadataExtensions.Relational([NotNullAttribute] this IEntityType entityType)
            if (item.Relational() is RelationalEntityTypeAnnotations extensions)
            {
                extensions.Schema = database;
            }
        }
like image 953
Ehasanul Hoque Avatar asked Nov 30 '25 22:11

Ehasanul Hoque


1 Answers

Based on the update log, your code will not work. You will need to use the flattened out versions.

Unfortunately, the issue 214 seems to still be open. I can see the GetSchema has been implemented already, but no SetSchema to be found. You could raise a new GitHub request to see when (if) it's getting there

Edit

There is a SetSchema check here. Kudos to Ivan Stoev.

Provider-specific Metadata API changes

Tracking Issue #214

New behavior

The provider-specific extension methods will be flattened out:

IProperty.Relational().ColumnName -> IProperty.GetColumnName() IEntityType.SqlServer().IsMemoryOptimized -> IEntityType.IsMemoryOptimized() PropertyBuilder.UseSqlServerIdentityColumn() -> PropertyBuilder.UseIdentityColumn()

Why

This change simplifies the implementation of the aforementioned extension methods.

Mitigations

Use the new extension methods.

like image 117
Athanasios Kataras Avatar answered Dec 02 '25 11:12

Athanasios Kataras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!