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

Reverse engineering a SQLite database with spatialite tables fails #2571

Open
andrerav opened this issue Oct 9, 2024 · 9 comments
Open

Reverse engineering a SQLite database with spatialite tables fails #2571

andrerav opened this issue Oct 9, 2024 · 9 comments
Labels

Comments

@andrerav
Copy link

andrerav commented Oct 9, 2024

Provide steps to reproduce a bug

  1. Create an empty sqlite database
  2. Load the mod_spatialite extension: SELECT load_extension('mod_spatialite');
  3. Initialize the spatial database: SELECT InitSpatialMetaData();
  4. Reverse engineer using SQLite driver:

image

5: Observe error message:

image

Provide technical details

  • EF Core Power Tools version: 2.6.497

  • Exact Visual Studio version: Version 17.12.0 Preview 2.0

  • Database engine: SQLite with Spatialite extension

  • EF Core version in use: EF Core 8

  • Is Handlebars templates used: no

  • Is T4 templates used: no

  • Is a SQL Server .dacpac used: no

@ErikEJ
Copy link
Owner

ErikEJ commented Oct 9, 2024

@andrerav First, EF Core Power Tools does not look at the code in your project.

Currently I have not enabled support for spatial with Sqlite, but I can investigate the possibility of doing this.

https://github.com/ErikEJ/EFCorePowerTools/wiki/Reverse-Engineering#mapping

@ErikEJ ErikEJ closed this as completed in 2974973 Oct 9, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Oct 9, 2024

I implemented a fix for this in the latest daily build, would be grateful if you could try it out.

@ErikEJ ErikEJ added enhancement New feature or request reveng reveng-cli labels Oct 9, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Oct 9, 2024

@andrerav The dailiy build is taking longer than expected, I will keep you posted

@ErikEJ ErikEJ reopened this Oct 9, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Oct 9, 2024

I was not able to do this, as the payload of my extension became unmanageable. I will revisit for EF Core 9, looks like the payload was smaller with that.

@andrerav
Copy link
Author

Hi @ErikEJ,

I was unable to get around this using EF Power Tools, so I went back to dotnet ef dbcontext scaffold and manually specified the tables I wanted to scaffold (using multiple -t arguments) to circumvent the problem and only scaffold my own tables (and not any of the spatialite meta tables).

Geometry columns are correctly generated as well provided that the Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite package is installed in the EF project.

If I don't specify the tables manually I get the same error message using dotnet ef as with EF Power Tools.

I think that being able to simply filter/specify the tables I want to scaffold could go a long way as a workaround for this issue.

@ErikEJ
Copy link
Owner

ErikEJ commented Oct 18, 2024

@andrerav The GUI is there to show all tables, perhaps the CLI will work better for you, though you might have to create the initial config file using a non spatial scracth database file.

@ErikEJ
Copy link
Owner

ErikEJ commented Oct 18, 2024

@andrerav hang on, are you saying that the tool should avoid discovering the spatial system files as well (and then also support the spatial EF Core plugin) for this to work?

Can you tell me what the names of these table are?

@andrerav
Copy link
Author

@ErikEJ If I create a new, empty Sqlite database, load the spatialite extension, and execute select InitSpatialMetadata();, I am left with these tables, indices and views:

image

A rather long list of triggers are created as well when initializing the spatial metadata.

@ErikEJ
Copy link
Owner

ErikEJ commented Nov 7, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants