✅ EFCore 8 MySQL - Table doesn't exist, but it does?
I'm trying to use EFCore to integrate with an existing database, but apparently the table doesn't exist, even though it clearly does. I'm manually writing the class for Products since EFCore didn't automatically generate it.
What the heck is going on here?
35 Replies
instead of manually writing the dbcontext, use scaffolding
I can't, DB has to be first
that's what scaffolding is
Reverse Engineering - EF Core
Reverse engineering a model from an existing database using Entity Framework Core
it generates classes from your existing database
Ah
then you don't risk making errors manually translating the schema
I've done that already, thats how I got some of the classes, it didn't pick up all the tables
It missed like half of them lol
that suggests some other issue, maybe permissions
it doesn't just randomly skip tables
yeah
you can enable more verbose logging in the scaffolding tool and see if there are any clues
ill try that
Got it to scaffold again, still skipping a bunch of tables. I'm using the root DB account, so it should have all the permissions it needs?
verbose doesn't seem to show anything either
what if you try to explicitly scaffold a table that it's skipping?
with
--table
It just does nothing
thats the command I used
-f to overwrite the DbContext
Correction, it doesn't do nothing, it just creates the DbContext and nothing else
I even tried switching providers from
Pomelo.EntityFrameworkCore.MySql
to the official MySql.EntityFrameworkCore
package, exact same thing. Same tables too
Its only doing the top 15 tablesweird, i haven't seen that before
what if you do something like a raw ado.net query to test if you can even access the tables from C# at a basic level?
Just tried that, same error
what if you make the same query in a non C# query console/tool?
actaully i mistyped the table name hold on
Yea same thing, doesn't exist
doing that command directly on the DB returns the table
as it should
maybe we just blame mysql and pick a different database :PepeLaugh:
I would love to
Now here's something interesting
I connected to the DB using WSL, (the database is running inside a docker container atm) and it can't find the table
There we go, it litterally cannot see the tables.
what a strange issue lmao
Stack Overflow
MySQL > Table doesn't exist. But it does (or it should)
I changed the datadir of a MySQL installation and all the bases moved correctly except for one.
I can connect and USE the database. SHOW TABLES also returns me all the tables correctly, and the fi...
maybe this is related?
if you copied the database you might have missed some metadata files that it needs
Its a clone of a db, so possibly actually
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
:kekw:
I'm losing my mind
if it's not that then i would have to say it's some kind of configuration/permission issue with external connections
but i don't touch mysql for other reasons so idk
Thats what i'm reading into at the moment
Prolly something to do with visibility externally or something idk
ive also never used mysql, and now I have the misfortune of using it for the first time on a project with a tight deadline lmao
if you got the database from somewhere else is there someone there that you can ask for help?
Yea, but conveniently he just went out of office for the week yesterday :broyai:
anyways, thank you for your help figuring this one out, I'll take it from here
If you have no further questions, please use /close to mark the forum thread as answered