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