{"id":23763879,"url":"https://github.com/tomashubelbauer/ef-sqlite","last_synced_at":"2026-04-25T22:34:00.939Z","repository":{"id":107986063,"uuid":"226726398","full_name":"TomasHubelbauer/ef-sqlite","owner":"TomasHubelbauer","description":"Reproducing an issue with migrations and table rebuilds I had in EF Core SQLite","archived":false,"fork":false,"pushed_at":"2022-04-14T20:14:06.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-03T11:32:16.075Z","etag":null,"topics":["ef","ef-core","entity-framework","entity-framework-core","migrations","sqlite"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomasHubelbauer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-08T20:22:47.000Z","updated_at":"2021-04-04T14:39:37.000Z","dependencies_parsed_at":"2023-05-15T11:00:37.990Z","dependency_job_id":null,"html_url":"https://github.com/TomasHubelbauer/ef-sqlite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TomasHubelbauer/ef-sqlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fef-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fef-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fef-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fef-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomasHubelbauer","download_url":"https://codeload.github.com/TomasHubelbauer/ef-sqlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fef-sqlite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32279656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ef","ef-core","entity-framework","entity-framework-core","migrations","sqlite"],"created_at":"2024-12-31T22:13:45.696Z","updated_at":"2026-04-25T22:34:00.934Z","avatar_url":"https://github.com/TomasHubelbauer.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EF Core SQLite\r\n\r\nSQLite has an EF Core provider, which is great, because SQLite is a RDBMS which\r\ncan run in-process unlike SQL Server, Postgres etc. but still has on-disk\r\npersistence unlike say the in-memory provider. Unfortunately, in SQLite, a lot\r\nof schema operations require table rebuilds, which are not supported in EF Core:\r\n\r\nhttps://github.com/aspnet/EntityFrameworkCore/issues/329\r\n\r\nThis repository demonstrates the problem.\r\n\r\n- `dotnet new console`\r\n- `dotnet add package Microsoft.EntityFrameworkCore.Sqlite`\r\n- Create `AppDbContext` with a single `DbSet` property of items\r\n- Create the `Item` model class with an ID and a name\r\n- Override `OnConfiguring` in `AppDbContext` to connect to SQLite\r\n- Reset the database and then insert, save and retrieve an item for a test\r\n  - Use `EnsureDeleted` following by `EnsureCreated` to carry out the reset\r\n- `dotnet run` to verify everything works\r\n- Reference the design package for EF tools:\r\n  `dotnet add package Microsoft.EntityFrameworkCore.Design`\r\n- Scaffold the initial migration:\r\n  `dotnet ef migrations add ScaffoldInitialSchema`\r\n- Create a new entity - `User` and reference it in an `Item` and vice-versa 1:N\r\n- Create a new `DbSet` for the user entity\r\n- Expand the demo code to create the user with the item and persist both at once\r\n- Scaffold a new migration capturing the new entity and relationships:\r\n  `dotnet ef migrations add AddUserEntityAndItemReference`\r\n- Replace the database reset with a `Migrate` call to force automated migration\r\n  - Or not replace but follow up?\r\n\r\n## To-Do\r\n\r\n### Retest now that SQLite table rebuilds have landed\r\n\r\nhttps://github.com/aspnet/EntityFrameworkCore/issues/329\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomashubelbauer%2Fef-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomashubelbauer%2Fef-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomashubelbauer%2Fef-sqlite/lists"}