Pomelo.entityframeworkcore.mysql: Problem with Schema Behaviour

Created on 13 Nov 2020  路  4Comments  路  Source: PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

Steps to reproduce

Ideally include a complete code listing that we can run to reproduce the issue.
Alternatively, you can provide a project/solution that we can run.

_Model is nothing special_
modelBuilder.Entity<BasicModelInOtherSchema>().ToTable("basic_in_other_schema", "dl_unit_test_history_core_other_schema");

static string Translator(string schema, string objectName) => $"{schema}.{objectName}";
optionsBuilder
             .UseLazyLoadingProxies()
             .UseMySql(_connectionString, ServerVersion.AutoDetect(_connectionString),
                    option => option.SchemaBehavior(MySqlSchemaBehavior.Translate, Translator)); 

The issue

I have an entity in another schema. With Pomelo 3 it works just out of the box, but with Pomelo 5 the schema is ignored by default. I tried to translate the schema with the translator, but the migration script to create the table is always invalid. There are backticks applied around the complete schema + tablename, so it cannot be parsed correct.

CREATE TABLE `dl_unit_test_history_core_other_schema.ignored_property_in_other_schema` (
    `Id` int NOT NULL AUTO_INCREMENT,
    `Value` longtext CHARACTER SET utf8mb4 NULL,
    `IgnoredValue` longtext CHARACTER SET utf8mb4 NULL,
    CONSTRAINT `PK_ignored_property_in_other_schema` PRIMARY KEY (`Id`)
);

Is that a bug or is there a simpler solution to my problem?

I did not find any hint from the ef core 5.0.0 changelog why this behaviour changed.

Thanks for your work ;)

Further technical details

MariaDb: 13.3.14
Operating system: Windows 10 x64
Pomelo.EntityFrameworkCore.MySql version: 5.0.0-alpha.2
Microsoft.AspNetCore.App version: 5.0.0

closed-question type-question

All 4 comments

@Zwergenpunk Which (exact) version of Pomelo were you using before? Because this is the expected behavior since some time ago now (so not a change between 3.2 and 5.0).

I explained somewhere, how it is still possible to misuse the EF Core concept of schemas for inter-database access with Pomelo (of course this is not officially supported). I can dig it up later in a couple of hours if you want (have to run now).

Duplicate of #1181, also see dotnet/efcore#22971 for further details.

@mguinness Thanks!
@Zwergenpunk The posted https://github.com/dotnet/efcore/issues/22971 link contains the sample code I was talking about in my previous post.

Yeah I did not upgrade von 3.2.x but from 3.1.x
That explains alot.

Thanks for your help.

Was this page helpful?
0 / 5 - 0 ratings