C
C#•3y ago
Skit

Update Database with EF core doesn't work and no error message

i am trying to create a database with ef core. Adding a migration works. Update database doesn't, with no error message. The connection string i am using works with other projects without ef.
35 Replies
Skit
SkitOP•3y ago
Skit
SkitOP•3y ago
if i try with rider gui, i am getting this error but doesn't seem useful either
Skit
SkitOP•3y ago
verbose output in terminal
Skit
SkitOP•3y ago
This is a console application. In razor projects i tried it works fine. Add migration, Update Database etc. I don't know if it helps narrowing down the issue, But i get the same behavior trying to "remove last migration" no error message or anything only "Add migration" seems to work
HappyTeaKid
HappyTeaKid•3y ago
1. Delete the migration folder in the project 2. In PackageManagerConsole(bottom left probably) write Add Migration Init 3. Delete your database and close connections 4. write in Console "Update-Database" Be sure to have extensions to manage your connection installed with the nugget package manager
V0FBU1VM
V0FBU1VM•3y ago
Show me your solution? And the registration of dbcontext.
Skit
SkitOP•3y ago
the first screenshot shows the installed nuget packages. Those are the ones I need, no?
Jayy
Jayy•3y ago
ur set is private so you wont be able to actually access it lol
Skit
SkitOP•3y ago
weird, it shows public for me
Jayy
Jayy•3y ago
Skit
SkitOP•3y ago
sry i thought you meant the repo is private 😆
Jayy
Jayy•3y ago
no, the set is private so youll never be able to interface with the tables
Skit
SkitOP•3y ago
ok i changed it, but i am still getting the same error
Jayy
Jayy•3y ago
ya thats not the specific problem would have just been the next problem as for ur migration issue, what is the rest of the verbose log output?
Skit
SkitOP•3y ago
the migration works, that verbose output was from update database
Jayy
Jayy•3y ago
ya i meant the application of the migration the screenshot cuts stuff off
Skit
SkitOP•3y ago
Jayy
Jayy•3y ago
is the server running?
Skit
SkitOP•3y ago
yep i can connect and use it with other applications
Jayy
Jayy•3y ago
can you connect to it with ssms so, does the database exist at all like was a CREATE run
Skit
SkitOP•3y ago
i did try it with creating the database beforehand and without but the tutorials i got the code from don't create database beforehand anyway
Jayy
Jayy•3y ago
database update will create the db if it doesnt exist
Skit
SkitOP•3y ago
yea it does for me in razor projects for example there it works just not in consoleapplication i find it just weird that i am not getting any proper error message at all nothing that even hints me to the issue
Jayy
Jayy•3y ago
that connection string is super weird
Skit
SkitOP•3y ago
i tried with user and password in it as well
Jayy
Jayy•3y ago
shouldnt server be uppercased Server
Skit
SkitOP•3y ago
quite sure i had it like that already gonna try again nope, doesn't help 😔
Jayy
Jayy•3y ago
im fairly certain its ur conection string run this dotnet ef database update -v diag
Skit
SkitOP•3y ago
same output as the verbose one
Data Source=localhost;database=PhoneBookDB;User ID=X;Password=X
Data Source=localhost;database=PhoneBookDB;User ID=X;Password=X
This is the connection string i use in another project which uses SQL, but not EF there it works
Jayy
Jayy•3y ago
Hmm I'll have to look at this a little I might pull it down and try, but i don't have sqlserver
Skit
SkitOP•3y ago
i found the issue in the dumbest way possible. While trying different connection strings, i missed the semicolon once. Looks like it doesn't work with Trusted_Connection
Skit
SkitOP•3y ago
thanks for helping
"MyCon": "Data Source=localhost;database=PhoneBookDB;User ID=USER;Password=Password
"MyCon": "Data Source=localhost;database=PhoneBookDB;User ID=USER;Password=Password
this is the string that worked after all bothers me that i couldn't see that from any error messages though
Jayy
Jayy•3y ago
what the hell thats like... the correct syntax?? thats bizzare
Want results from more Discord servers?
Add your server