亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Npgsql.NpgsqlException: '沒有提供密碼

Npgsql.NpgsqlException: '沒有提供密碼

C#
慕工程0101907 2022-06-12 14:45:06
我是 dotnet core、Entity framework core 和 PostgreSQL 的初學者。我在 ConfigureServices 方法中與數據庫建立連接,如下所示:public void ConfigureServices(IServiceCollection services)    {                    services.AddOptions();        string databaseConnection = "Server=localhost;Port=5432;Database=EF_Lesson Username=postgres password=123;Integrated Security=false;";        services.AddDbContext<EF_LessonContext>(            options => options.UseNpgsql(databaseConnection)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);    }下面是我的控制器類如下:[Route("ToLesson")][ApiController]public class EF_LessonController : ControllerBase{    private readonly EF_LessonContext _context;    public EF_LessonController(EF_LessonContext context)    {        _context = context;        if (_context.Webserverlogin.Count() == 0)        {            _context.Webserverlogin.Add(new Webserverlogin() {  });            _context.SaveChanges();        }    }    [HttpGet]    public ActionResult<List<Webserverlogin>> GetAll()    {        return _context.Webserverlogin.ToList();    }}但我在控制器類的構造函數中收到錯誤,因為 Npgsql.NpgsqlException:'沒有提供密碼,但后端需要一個(在 MD5 中)'我已經搜索了 2 個小時,但在我的情況下沒有任何效果。有人建議我只需要在一個我已經在做的地方使用連接。無論如何,請建議我擺脫這個錯誤。
查看完整描述

1 回答

?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

您錯過了連接字符串中登錄名和密碼之間的分號。請看例子


查看完整回答
反對 回復 2022-06-12
  • 1 回答
  • 0 關注
  • 383 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號