Skip to content

Imlementation for Support specifying catalog for table mapping (initial PR) - #4672

Closed
laskoviymishka wants to merge 1 commit into
dotnet:devfrom
laskoviymishka:overrideDatabaseName
Closed

laskoviymishka wants to merge 1 commit into
dotnet:devfrom
laskoviymishka:overrideDatabaseName

Conversation

@laskoviymishka

Copy link
Copy Markdown
Contributor

(fix issue #4019)

  • Add database property to relational type annotations
  • Follow this property from explicit mapping to default query sql generator (to create proper table alias including database name)
  • Enhance relational model validator to including database name (this will allow have same table and schemas for different databases)
  • Enhance model configuration - add generator for proper toTable method if database is presented

There are still some open questions:

  1. There is no database/catalog propery in TableAttribute.

So we could not implement data annotation mapping to different database. There is a possible solution by introducing additional attribute for this need (like DatabaseAttribute) with single proprte Name. In this case usage could be fairly simple

[Database("Pink")]
[Table("Unicorns", Schema="Fluffy")]
class DifferentDatabaseItem{ }

Instead of:

 modelBuilder.Entity<MappingQueryTestBase.DifferentDatabaseItem>(e =>
            {
                e.Metadata.Relational().TableName = "Unicorns";
                e.Metadata.Relational().Schema = "Fluffy";
                e.Metadata.Relational().Database = "Pink";
            });

But there is a lot more implementation needed to add such attribute. It require add Database property to every migration command and follow it from code gen to query generation.

  1. There is issues with navigation properties and foreign keys between databases. We could join tables but could not generate proper foreign key without hacks.

…(fix issue dotnet#4019)

- Add database property to relational type annotations
- Follow this property from explicit mapping to default query sql generator (to create proper table alias including database name)
- Enhance relational model validator to including database name (this will allow have same table and schemas for different databases)
- Enhance model configuration - add generator for proper toTable method if database is presented
@rowanmiller

Copy link
Copy Markdown
Contributor

Hey,

We're going to close this one out as we would need a complete implementation of catalog support in order to take it at this stage. Some of the key things missing from this so far are migrations support and a top level fluent API (currently needs to be set via lower level metadata APIs).

There are also some open design issue here. Most notably, should this be a relational concept, or specific to SQL Server. Feel free to open up an issue to start hashing these design concerns out - or use the existing #4019.

We are very willing to take this feature, but given that the pull request needs more than just some minor changes before we would accept it, we're going to close the PR for the moment.

~Rowan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants