✅ ef not being able to update database migrations
I've been trying to learn aspnet and done just the basics of it. But when using
dotnet ef database update
, after adding a migration, the same SQLite Error 1: 'no such table: __EFMigrationsHistory'.
happens, eventhough that table is being created (or was supposed to be created) on the initial migration.
I only have 1 service and 1 model now, so that error makes no sense for me, as it's the only language that happened for me.39 Replies
The database was fully created by ef and it'll be only used by ef
@sunpoke04 How did you create the database?
.
I didn't even touch the db.
This example from the offical docs uses SQLite:
- https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli
Compare, see if you miss something
they used the same commands as me.
Show the code for the Database Context
I haven't even put anything inside that set, just trying to create it
Do you think it's the same as what's shown in their example?
yes.
Since it's being setup in the Program.cs
Show it...
?
What's in Program.cs
builder.Services.AddDbContext<ApplicationDbContext>(opt => opt.UseSqlite(builder.Configuration.GetConnectionString("SqliteConnection")));
again, I'm not an idiot.
I am configuring it.it's the same thing, written on a different way
Do you have the path defined as an absolute path?
the db path is being defined in the appsettings.json.
I'm not gonna show that.
In that, the db is being created, with the tables. And the migrations are being applied.
My migrations are never being updated.
You said your first migration applied, no?
I could create a migration, I can't update to db.
that's the title of this channel
Nvm, that happens on the initial migration / first update?
Since you don't seem to understand it
I did understand, I'm asking if that happens the first time you use "dotnet ef database update" or the second time
every time...
doesn't matter how many times I run it, it does the same thing
Ok, you said you have your path in appsetting.json. Is it an absolute or relative path?
something like
Data Source=somedblikethat.db
It's relative then. That's your problem I think
Try with a full/absolute path
it still should do whatever it does
Anything?
nothing changed
yes, I dropped the old db before doing another update.
It's a new app? Will try here
?
Version 6?
I will try to create a new app here
Dotnet version 6? 7?
7
I followed the example and had no problem creating it
Just had problem finding the db lol
?
then what would be the problem?
because everything looks like it should work
but it doesn't
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.no, the command is still not working