C
C#12mo ago
treesgobark

✅ Docker + Blazor + EF Core 7 + SQLite = __EFMigrationsHistory doesnt exist

Hello everyone i am new to docker and i am attempting to containerize an existing project. I've got a .NET 7 blazor server app using EF core 7 with sqlite. It works fine running via the typical methods using IIS express, but when it goes into my docker container, applying the EF migrations causes a SQL error at the end where it can't find my __EFMigrationsHistory table, even though it shows creating that table at the very beginning of the logs. The only reference i found online that seemed like it could be relevant was this one: https://stackoverflow.com/questions/42393128/entityframeworkcore-for-sqlite-not-creating-efmigrationhistory-table but it's super out of date and their project seems to run just fine on the first runthrough whereas mine does not. I'll leave it here in case someone can find a hint in there. Attached file contains my compose file, dockerfile, and the console output from the container
Stack Overflow
EntityFrameworkCore for Sqlite not creating __EFMigrationHistory table
Before I explain my issue, I have some experience with entity framework 5 and 6 code first migrations, running add-migration/update-database and a few more specific commands from the Package Manager
5 Replies
heloo
heloo12mo ago
hi i ran into this issue and this fixed it using Microsoft.EntityFrameworkCore; using Final.Models; namespace Final.Data { public class DataContext : DbContext { protected readonly IConfiguration Configuration; public DataContext(IConfiguration configuration) { Configuration = configuration; } protected override void OnConfiguring(DbContextOptionsBuilder options) { // connect to sqlite database options.UseSqlite(Configuration.GetConnectionString("WebApiDatabase")); } public DbSet<User> Users { get; set; } } } add the connection string in the DataContext file not program.cs hope this works for you as well
treesgobark
treesgobark12mo ago
unfortunately i already do that i have mine in the DBContext.OnConfiguring like you do are you sure that's what actually fixed it? you could have made another change at the same time that actually was the answer
heloo
heloo12mo ago
iam unfortunately clueless on this error
treesgobark
treesgobark12mo ago
i managed to dodge this issue somehow so i guess it's gone hooray... would have liked to have an actual fix but we take what we can get
Accord
Accord12mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts