Skip to content

Add automatic database initialization using EnsureCreated#15

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/sub-pr-14
Draft

Add automatic database initialization using EnsureCreated#15
Copilot wants to merge 5 commits intomainfrom
copilot/sub-pr-14

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 8, 2026

The Readings DbSet was added to AppDbContext without database initialization, causing "no such table: Readings" runtime errors when hitting the new endpoints.

Changes:

  • Added automatic database creation on startup via dbContext.Database.EnsureCreated() in Startup.Configure()
  • Updated .gitignore to exclude SQLite temporary files (*.db-shm, *.db-wal) and Migrations folder
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AppDbContext dbContext)
{
    // Ensure database is created on startup
    dbContext.Database.EnsureCreated();
    // ...
}

Database schema is created automatically from the EF Core model on first run without requiring migration files.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 8, 2026 14:39
Co-authored-by: joaoferreira-dev <63664299+joaoferreira-dev@users.noreply.github.com>
Co-authored-by: joaoferreira-dev <63664299+joaoferreira-dev@users.noreply.github.com>
Co-authored-by: joaoferreira-dev <63664299+joaoferreira-dev@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on Reading.cs model and endpoint methods Add EF Core migration and automatic database initialization Feb 8, 2026
Copy link
Copy Markdown
Member

@joaoferreira-dev joaoferreira-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I think it is not supposed to commit the Migrations folder neither app.db-shm nor aapp.db-wal

…tead

Co-authored-by: joaoferreira-dev <63664299+joaoferreira-dev@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot I think it is not supposed to commit the Migrations folder neither app.db-shm nor aapp.db-wal

You're correct. I've removed the Migrations folder and the SQLite temporary files (app.db-shm, app.db-wal) from the repository.

Updated approach:

  • Changed from Database.Migrate() to Database.EnsureCreated() for automatic database creation
  • Updated .gitignore to exclude Migrations folder and SQLite temp files (*.db-shm, *.db-wal)
  • Database schema is now created directly from the EF Core model on startup

Fixed in commit c7ac9ac.

Copilot AI changed the title Add EF Core migration and automatic database initialization Add automatic database initialization using EnsureCreated Feb 8, 2026
Base automatically changed from feature/Reading-Model to main February 8, 2026 15:28
@joaoferreira-dev joaoferreira-dev added the wontfix This will not be worked on label Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants