Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations: SQLite should ignore schema rather than throwing. #6679

Closed
bricelam opened this issue Oct 4, 2016 · 3 comments
Closed

Migrations: SQLite should ignore schema rather than throwing. #6679

bricelam opened this issue Oct 4, 2016 · 3 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@bricelam
Copy link
Contributor

bricelam commented Oct 4, 2016

Asked by @VorSiechtIP (or a user with the same name) on StackOverflow:

I have a shared model that will be used to create both SqlServer and SQLite databases. I added the Table attribute onto each one of my model classes and supplied a schema:

[Table("Sites", Schema = Common)]

When I migrate the SQLite database using context.Database.Migrate(), I get a NotSupportedException error. I know that SQLite doesn't support schemas, so I was wondering if there was an easy way to ignore the schema attribute during migrate?

@bricelam
Copy link
Contributor Author

bricelam commented Oct 4, 2016

I suspect the reason this is happening is because the migration was generated with the SQL Server provider active. This would scaffold the schema name into the migration. If SQLite was active, these would not be scaffolded.

This was the original design: Strip schemas out when generating the migration, but throw if the user tries to explicitly specify one since they're note supported on SQLite. This, however, makes creating provider-agnostic migrations unnecessarily difficult and we should consider just ignoring them in the Migrations SQL generator too.

@rowanmiller rowanmiller added this to the 1.2.0 milestone Oct 6, 2016
@bricelam bricelam changed the title Ignore schema attribute for SQLite during migration? SQLite Migrations: Ignore schema Oct 6, 2016
@Allann
Copy link

Allann commented Jan 3, 2017

Get the same error if the OnModelCreating (in a DbContext) is called with the line:

modelBuilder.HasDefaultSchema("Maintenance");

As a suggestion, could this not be:

modelBuilder.ForSqlServerHasDefaultSchema("Maintenance");

that way it is configured only for SqlServer and is ignored in other provider types.

As it currently stands, it is implied the the command works for ALL provider types.

@bricelam
Copy link
Contributor Author

In addition to ignoring schemas in Migrations (and EnsureCreated()), we decided to warn during model building if a schema is specified. We'll also warn when a sequence is specified since they are also not supported by SQLite.

@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Feb 27, 2017
@ajcvickers ajcvickers changed the title SQLite Migrations: Ignore schema Migrations: SQLite should ignore schema rather than throwing. May 9, 2017
@divega divega added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels May 10, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

5 participants