數(shù)據(jù)庫打開失敗是為什么呢?
我配置好了appsettings這個文件,DataBase的名字我改成我自己數(shù)據(jù)庫的名字了,但是他提示我這個
“SqlException: Cannot open database "Student_DB" requested by the login. The login failed.
Login failed for user 'DESKTOP-DJ53LJD\Administrator'.”
我配置好了appsettings這個文件,DataBase的名字我改成我自己數(shù)據(jù)庫的名字了,但是他提示我這個
“SqlException: Cannot open database "Student_DB" requested by the login. The login failed.
Login failed for user 'DESKTOP-DJ53LJD\Administrator'.”
舉報
2022-11-06
你把Students? 改成Student 就行了 不要s
2021-07-01
已解決,是鏈接字符串寫錯了,應(yīng)該這樣寫:"DefaultConnection": "Data Source=.;Initial Catalog=Student_DB;Integrated Security=True"
但是雖然這個問題解決了又遇到了一個新的問題,那就是在“對象名 'Students' 無效,”students在DBcontext內(nèi)里定的"public DbSet<Student> Students { get; set; }",程序在編譯階段沒報錯,但是在執(zhí)行時就會報錯。