R
Railway5mo ago
Vorlon

Setting up DB with EFCore?

I am trying to migrate a DB to railway. I used to use SQLite with EFCore (I am in a C# .NET environment) , but after reading other threads I have heard it is discouraged so I am trying to transition from SQLite to postgres. I have an empty postgres DB running in my project and I took the URL and tried to run dotnet ef database update but I keep getting this error:
System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
19 Replies
Percy
Percy5mo ago
Project ID: 465462e9-fa14-41fc-8798-1f21e3c51faa
Vorlon
VorlonOP5mo ago
465462e9-fa14-41fc-8798-1f21e3c51faa
Brody
Brody5mo ago
the URL might not be in the format that the client wants, can you show me the URL format that is expected?
Vorlon
VorlonOP5mo ago
postgresql://myusername:mypassword@localhost:5432/mydatabase maybe this? I guess that is different from the private url
Brody
Brody5mo ago
that would be the format the databases do come with, but what does your client expect the format to be?
Vorlon
VorlonOP5mo ago
i am unsure of what you mean ok I uised A NpgsqlConnectionStringBuilder to fix the formatting issue, but now I have something which I am unsure of how to about
System.Net.Sockets.SocketException (11001): No such host is known.
System.Net.Sockets.SocketException (11001): No such host is known.
which is correct but how do I run the command inside of railway?
Brody
Brody5mo ago
are you attempting to the the private url locally?
Vorlon
VorlonOP5mo ago
oh snap... yes yaaay thanks I now have tables on rail but can I ask also, do you have any suggesitons to input a mass amount of data? since I am trying to move my db
Brody
Brody5mo ago
well where is this data coming from?
Vorlon
VorlonOP5mo ago
the db is currently on my pc (this is all a test environment before I migrate the real thing)
Brody
Brody5mo ago
what kind of db
Vorlon
VorlonOP5mo ago
a sqlite db currently but I am trying to convert it to a postgress one
Brody
Brody5mo ago
off the top of my head I'm not aware of any solutions to copy data from sqlite to postgres I'm sure that's something someone has done before so do some research on the topic
Vorlon
VorlonOP5mo ago
While trying to read my data from a deployment on railway, I am getting the error: System.ArgumentNullException: Value cannot be null. from the line:
Environment.GetEnvironmentVariable("DATABASE_PRIVATE_URL");
Environment.GetEnvironmentVariable("DATABASE_PRIVATE_URL");
which made me realize the variables on the postgres db cannot be seen from the other service (the actual bot) is there a way I am supposed to go about this?
Brody
Brody5mo ago
yep! you want to be using reference variables, the docs for that are here along with an example - https://docs.railway.app/guides/variables#referencing-another-services-variable
Vorlon
VorlonOP5mo ago
hmm, so if my postgres db was called Postges I would use Postges.DATABASE_PRIVATE_URL
Brody
Brody5mo ago
almost, you do need the surrounding characters - ${{Postges.DATABASE_PRIVATE_UR}}
Vorlon
VorlonOP5mo ago
Oh I see, that part is in railway I now have a connection
Brody
Brody5mo ago
awsome
Want results from more Discord servers?
Add your server