C
C#•2y 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
Skit•2y ago
Skit
Skit•2y ago
if i try with rider gui, i am getting this error but doesn't seem useful either
Skit
Skit•2y ago
verbose output in terminal
Skit
Skit•2y 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•2y 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
SwaggerLife
SwaggerLife•2y ago
Show me your solution? And the registration of dbcontext.
Skit
Skit•2y ago
the first screenshot shows the installed nuget packages. Those are the ones I need, no?
Jayy
Jayy•2y ago
ur set is private so you wont be able to actually access it lol
Skit
Skit•2y ago
weird, it shows public for me
Jayy
Jayy•2y ago
Skit
Skit•2y ago
sry i thought you meant the repo is private 😆
Jayy
Jayy•2y ago
no, the set is private so youll never be able to interface with the tables
Skit
Skit•2y ago
ok i changed it, but i am still getting the same error
Jayy
Jayy•2y 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
Skit•2y ago
the migration works, that verbose output was from update database
Jayy
Jayy•2y ago
ya i meant the application of the migration the screenshot cuts stuff off
Skit
Skit•2y ago
Jayy
Jayy•2y ago
is the server running?
Skit
Skit•2y ago
yep i can connect and use it with other applications
Jayy
Jayy•2y ago
can you connect to it with ssms so, does the database exist at all like was a CREATE run
Skit
Skit•2y 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•2y ago
database update will create the db if it doesnt exist
Skit
Skit•2y 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•2y ago
that connection string is super weird
Skit
Skit•2y ago
i tried with user and password in it as well
Jayy
Jayy•2y ago
shouldnt server be uppercased Server
Skit
Skit•2y ago
quite sure i had it like that already gonna try again nope, doesn't help 😔
Jayy
Jayy•2y ago
im fairly certain its ur conection string run this dotnet ef database update -v diag
Skit
Skit•2y 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•2y 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
Skit•2y 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
Skit•2y 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•2y ago
what the hell thats like... the correct syntax?? thats bizzare
Want results from more Discord servers?
Add your server
More Posts
dependency injection net frameworkhi all, I'm following a reference on how to use dependency injection in net framework https://stackSafe to ignore non-null value on exit contructor? (disabling warning)Can I safely add this as a ignore? I don't really know how I would fix this otherwiseHow should I start learninghi everybody I started learning c#, going through basics and want to ask those who in industry alreaCreating an instance of a class using DI [Answered]This is purely just out of curiosity. If you have a class which takes some arguments in its ctor andIs there any benefit to write a Property with a private variable ?Why: ```cs private int myVar; public int MyVar { get => myVar; set => myVar = value; } ``` may be beHow add analyzer for suggesting to add missing parameters or removing them?Soo I have analyzer which checks if parameter type is proper soo then I need to make codefix which j[ASP.NET] B-Logic Services, ValidationI am using anemic models, therefore I want to implement Business Logic Services. And the questions Optimizing some string manipulationI want to both substring an input string at the last occurrence of `'/'` and normalize it into *onlyRight way to use Interfaces in Large Scale Blazor Server Web ApplicationsHello there, iam currently working on a <see title> app for something iam not allowed to leak now iaUsing dependency injection for internal classes inside a libraryI'm making a library, where I feel like it would be useful to be able to use Microsoft's dependency