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