C
C#8mo ago
Protagonist

EntityFramework & Supabase

I'm trying to connect to my database on superbase and i put it as my connection string. I then run migration and its successful but it doesn't subscribe that migration to Supabase. So how would i be able to do that?
38 Replies
Angius
Angius8mo ago
What do you mean "doesn't subscribe"?
Protagonist
ProtagonistOP8mo ago
As in when i do the migration, the database in supabase is empty
Angius
Angius8mo ago
Migrations, usually, don't insert any data They're just a way of versioning the database structure
Salman
Salman8mo ago
do you update the database after you run migrations ?
Angius
Angius8mo ago
That's a good question as well, yeah
Salman
Salman8mo ago
yeah sounds like he's only running migrations and not updating the db afterwards
Protagonist
ProtagonistOP8mo ago
ah yes how silly of me lemme do that
Protagonist
ProtagonistOP8mo ago
so i did it and i see that theres some migrationhistory
No description
Protagonist
ProtagonistOP8mo ago
how can i see the tables in my db from this?
Angius
Angius8mo ago
You're looking at the table that stores migration history You don't seem to have any other tables Did you set them up the dbcontext properly? Do you have dbsets there?
Protagonist
ProtagonistOP8mo ago
these 3 tables should be set
No description
Salman
Salman8mo ago
Well we don't know how your db context or entities look like and how you're migrrating and updating the db
Protagonist
ProtagonistOP8mo ago
and it says in my output that its done correct with no errors
Salman
Salman8mo ago
is this context registered in your program.cs ?
Protagonist
ProtagonistOP8mo ago
yes
Salman
Salman8mo ago
also make sure your connection string is correct , and check the migration file after you run migrations because from that file you'd know how the tables in your db would look like
Protagonist
ProtagonistOP8mo ago
the string must be correct since EFmigrationhistory is in supabase, the migration file also looks correct and shows the diff tables and column wait okay so i moved the order of somethings in dbcontext, based of what tables need to be created first. THen i run add migration and initalcreate up n down method is empty but the design of it isnt weird
Salman
Salman8mo ago
ordering of tables doesn't matter in this context do you run Update-Database command ?
Protagonist
ProtagonistOP8mo ago
The problem seems before that? when i do migration
Protagonist
ProtagonistOP8mo ago
No description
Protagonist
ProtagonistOP8mo ago
but my design file of it is
No description
Protagonist
ProtagonistOP8mo ago
then i run database update anyway and stil lsame issue
Protagonist
ProtagonistOP8mo ago
when i run update database i only get this back, should it also show my tables being added?
No description
Angius
Angius8mo ago
I'd try deleting migrations, deleting the migration history table from db, creating a new migration, applying that
Protagonist
ProtagonistOP8mo ago
okay imma try now hehe thank you it worked 😍 still one same topic of ef and Supabase. If i have a REST Api, does supabase support hosting that API or would i have to host elsewhere? because i assume for API it would want me to use the supabase library which means i wont be able to use the way ive done it with EF, right?
Angius
Angius8mo ago
I don't think Supabase offers .NET hosting They do support serverless functions, so you can build your API on that
Protagonist
ProtagonistOP8mo ago
hmm do you know of one that does .NET hosting? my azure is messed up so has to be another service
Angius
Angius8mo ago
No mention of a VPS offer, just edge functions
No description
Angius
Angius8mo ago
And this tells me their edge functions probably run on V8
No description
Angius
Angius8mo ago
So JS and Wasm
Protagonist
ProtagonistOP8mo ago
Im not even sure wat edge functions are. but TS and WASM means web applications correct?
Protagonist
ProtagonistOP8mo ago
also here it says something API related
No description
Angius
Angius8mo ago
Yes, Supabase can wrap your database in an API layer And you can use that API instead of connecting with the db directly
Protagonist
ProtagonistOP8mo ago
so will it be like you send your CRUD requests for example directly to the url then it will add it to the db or fetch from the db? usuage of connection string will still have to be in use right
Angius
Angius8mo ago
The connection string lets you connect to the database If the database is behind an API, you don't need the connection string You just call https://my-cool-project.supabase.com/items?id=18 and that's it That gets you the item with id equal 18
Protagonist
ProtagonistOP8mo ago
thats pretty neat what about this API key will i have to place it in my headers via code for the requests to work? Your API is secured behind an API gateway which requires an API Key for every request.
Angius
Angius8mo ago
Maybe Idk, it's probably in the docs Never used Supabase myself
Protagonist
ProtagonistOP8mo ago
tbh so far it seems pretty neat, documentation and UI Functionality wise im yet to explore
Want results from more Discord servers?
Add your server