Get access to actual connection for migration
See original GitHub issueIn my case I need add some specific settings in Migration file.
migrationBuilder.Sql(sqlcode)
If I correctly understand all operation in migration uses MasterConnection (postgres database). https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/blob/8e97e4195b197ae3d16763704352acfffa95c73f/src/EFCore.PG/Storage/Internal/NpgsqlDatabaseCreator.cs#L41
But for my settings I need actual connection to actual database. Can I somehow get access to connection. Maybe I can inherit from NpgsqlDatabaseCreator and use connection directly https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/blob/8e97e4195b197ae3d16763704352acfffa95c73f/src/EFCore.PG/Storage/Internal/NpgsqlDatabaseCreator.cs#L22
Maybe there are other ways?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to get the current connection string inside an Entity ...
This works when you have a 'running' DbContext. using (var db = new YourDbContext()) { var connection = db.Database.Connection.
Read more >Migration guide: Access to SQL Server
This guide teaches you how to migrate your Microsoft Access databases to Microsoft SQL Server by using SQL Server Migration Assistant for ...
Read more >How to transfer data from your old Mac to a new ... - YouTube
Learn how to use Migration Assistant to transfer information from your ... A terrible way to transfer to a new Mac as using...
Read more >Use the Migration Dashboard to Migrate to Workspace ...
In the Migration dashboard, in the Install the latest Workspace ONE Access Connector(s) section, click Get Started.
Read more >Migration Plans: Sites
The first step when creating a migration plan in the Tableau Content Migration Tool is to sign in to the source and destination...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m sorry I really was wrong. Raw SQL work fine.
My problem was in custom NpgsqlMigrationsSqlGenerator. I tryed reimplement Generate method to append some sql commands: https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/blob/89b9742df7bebab9bdc92f259bb6ecf66da30365/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs#L601
I was inattentive. @roji @austindrenski Thank you for help.
I’m probably misunderstanding something here, but the master connection is only used to create the database. The rest of the migration code - table creation and any additional raw SQL - happens on the regular connection to the database. So any ALTER DATABASE statement you specify in raw SQL should actually work fine. Can you please double-check and provide more detail?
Aside from that, we do support specifying the tablespace on the database, mainly because this is an option that must be specified in
CREATE DATABASE
and cannot be altered later. We can support other database creation (and alteration) options as needed, but anything that can be altered later should be easily doable with raw SQL.