when connecting database 404 not found error
I created a db from docker and created db in mysql. After that I build a mini backend with ef core and asp net for homework but I couldn't manage to connect it. My connection string is correct
68 Replies
are you using Docker Desktop on a windows PC?
im using docker desktop on mac
okay. And the database container shows up as expected in the docker desktop GUI?
and has status "running" etc?
yes it's running
also I managed to connect mysql from terminal while running in docker
with the terminal on the host machine, right?
using mysql cli
this packages are true right
yes.
Im not sure I'd use
MySql.EntityFrameworkCore
what would you use I'll try
Pomelo.EntityFrameworkCore.MySql
let me trry
in general, mysql isnt a very good database, and the official connector has had issues in the past
im not sure if its still true
I can change db now it's okay if you say not very good
what can I use else
postgres is very good
Npgsql.EntityFrameworkCore.PostgreSQL
is the EFcore connector for thatI gotta create new container for postgres but I want to know that problem is mysql or my codes
after pomelo mysql package I got this error
I think its not about package too I am getting not found error again
can you show a screenshot from docker desktop container overview window, and your connection string?
running one is my container
"server=localhost;port=3306;database=ENSAR;uid=root;password=ensarerdeve2001;"
its my connection string
sorry about the late answer
what do you say it might be the code part?
Hard to say.
can I share the db context and program.cs with you
sure. $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/
don't mind the default weather thing
why do I get the distinct feeling that I've helped you before with this?
The name "ENSAR" in all caps...
that's the db name. That's my first time with ef core
you see any obvious mistakes?
why are you declaring the provider twice?
you do it both in program.cs with
AddDbContext
(correct) and in the context itself in OnConfiguring
(bad wrong delete!)so onconfiguring is unnecessary
yes
does "ensar" mean anything special? I have definately seen that database name before a few months ago helping someone on here
its my name. that was me probably. I was working with ado.net that time
db is running but still getting not found error.
can you show me the command you run in the terminal to connect to it?
from the host machine
you meant this?
no, the mysql cli
so, thats not the same
thats using docker to tunnel into the container
its not connecting from the host
I didn't tried to connect directly mysql from terminal
well you need to verify that the container can be reached from the host
how can I verify
you could get something like heidisql or mysql workbench or something
and try to connect using that
so I should always have a program like that right
for verify that I can connect except from docker
¯\_(ツ)_/¯
always and always
what do you say dbeaver is it useful
if you are having issues connecting, the first step should be to verify that you CAN connect at all
never heard of it. I have not used mysql in many many years
(because its a garbage database)
oh gotcha. can you tell me the reason why it's garbage. I want to get knowledge about it
$whynotmysql
https://dev.mysql.com/doc/refman/8.0/en/insert.html
Inserting NULL into a column that has been declared NOT NULL. For multiple-row INSERT statements or INSERT INTO ... SELECT statements, the column is set to the implicit default value for the column data type. This is 0 for numeric types, the empty string ('') for string types, and the “zero” value for date and time types. INSERT INTO ... SELECT statements are handled the same way as multiple-row inserts because the server does not examine the result set from the SELECT to see whether it returns a single row. (For a single-row INSERT, no warning occurs when NULL is inserted into a NOT NULL column. Instead, the statement fails with an error.) Setting a numeric column to a value that lies outside the column range. The value is clipped to the closest endpoint of the range. Assigning a value such as '10.34 a' to a numeric column. The trailing nonnumeric text is stripped off and the remaining numeric part is inserted. If the string value has no leading numeric part, the column is set to 0. Inserting a string into a string column (CHAR, VARCHAR, TEXT, or BLOB) that exceeds the column maximum length. The value is truncated to the column maximum length. Inserting a value into a date or time column that is illegal for the data type. The column is set to the appropriate zero value for the type.
$whynotmysql2
oracle
hah, that last one is new 😄
but also not wrong. Oracle is a pretty terrible company
the very best reason was a blog article written by Steinar Gunderson that seems to have been deleted, but here is a quote
After five years in Oracle’s MySQL team, Steinar H. Gunderson resigned a few days ago. On the same day, he dropped the bomb on his blog: let me point out something that I’ve been saying both internally and externally for the last five years (although never on a stage—which explains why I’ve been staying away from stages talking about MySQL): MySQL is a pretty poor database, and you should strongly consider using Postgres instead1.
uhh I see
btw should I connect to db from docker ip or localhost? or both same?
now I will connect through workbench
localhost or
127.0.0.1
are the same thing
if connecting from the host machine, either should be fineI managed to connect from host machine
so high chance the problem code part
what exactly is the error message?
there is no message directly it just says 404 not found
no way
thats a http error
I highly doubt your database connection would "throw" a 404 not found
I found the article reposted on a chinese blog-aggregator https://www.cnblogs.com/dbadaily/p/mysql-or-postgresql.html
I'll try to change mysql now maybe the problem itself is mysql
it really isnt
its something else going wrong now, not the database connection
I started to vscode 2-3 days ago am I missing some kind packages maybe
no, the 404 error is not from your database connection
I have warn something like
BlazeBin - ymqktkoipssp
A tool for sharing your source code with the world!
can you check my controller
return NotFound();
would give a 404 not found
thats literally what that line of code does
set a breakpoint in the route you are trying to hit, and then hit it
step through your functions, see whats happeningoh I've solved the problem by adding
added these and after when I try to get method it started to response and said no table and I did the migration