C
C#9mo 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
Angius9mo ago
What do you mean "doesn't subscribe"?
Protagonist
ProtagonistOP9mo ago
As in when i do the migration, the database in supabase is empty
Angius
Angius9mo ago
Migrations, usually, don't insert any data They're just a way of versioning the database structure
Salman
Salman9mo ago
do you update the database after you run migrations ?
Angius
Angius9mo ago
That's a good question as well, yeah
Salman
Salman9mo ago
yeah sounds like he's only running migrations and not updating the db afterwards
Protagonist
ProtagonistOP9mo ago
ah yes how silly of me lemme do that
Protagonist
ProtagonistOP9mo ago
so i did it and i see that theres some migrationhistory
No description
Protagonist
ProtagonistOP9mo ago
how can i see the tables in my db from this?
Angius
Angius9mo 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
ProtagonistOP9mo ago
these 3 tables should be set
No description
Salman
Salman9mo ago
Well we don't know how your db context or entities look like and how you're migrrating and updating the db
Protagonist
ProtagonistOP9mo ago
and it says in my output that its done correct with no errors
Salman
Salman9mo ago
is this context registered in your program.cs ?
Protagonist
ProtagonistOP9mo ago
yes
Salman
Salman9mo 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
ProtagonistOP9mo 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
Salman9mo ago
ordering of tables doesn't matter in this context do you run Update-Database command ?
Protagonist
ProtagonistOP9mo ago
The problem seems before that? when i do migration
Protagonist
ProtagonistOP9mo ago
No description
Protagonist
ProtagonistOP9mo ago
but my design file of it is
No description
Protagonist
ProtagonistOP9mo ago
then i run database update anyway and stil lsame issue
Protagonist
ProtagonistOP9mo ago
when i run update database i only get this back, should it also show my tables being added?
No description
Angius
Angius9mo ago
I'd try deleting migrations, deleting the migration history table from db, creating a new migration, applying that
Protagonist
ProtagonistOP9mo 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
Angius9mo ago
I don't think Supabase offers .NET hosting They do support serverless functions, so you can build your API on that
Protagonist
ProtagonistOP9mo ago
hmm do you know of one that does .NET hosting? my azure is messed up so has to be another service
Angius
Angius9mo ago
No mention of a VPS offer, just edge functions
No description
Angius
Angius9mo ago
And this tells me their edge functions probably run on V8
No description
Angius
Angius9mo ago
So JS and Wasm
Protagonist
ProtagonistOP9mo ago
Im not even sure wat edge functions are. but TS and WASM means web applications correct?
Protagonist
ProtagonistOP9mo ago
also here it says something API related
No description
Angius
Angius9mo 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
ProtagonistOP9mo 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
Angius9mo 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
ProtagonistOP9mo 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
Angius9mo ago
Maybe Idk, it's probably in the docs Never used Supabase myself
Protagonist
ProtagonistOP9mo 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