Get the Entity Framework Connection String

前端 未结 11 994
迷失自我
迷失自我 2021-01-31 02:27

We use Entity Framework 5, but have a requirement to ALSO use a normal database connection from the application for some custom SQL we need to perform.

So, I am creating

11条回答
  •  不知归路
    2021-01-31 03:16

    Hope it helps..

        private readonly ApplicationDbContext _applicationDbContext;
        string connectionString = string.Empty;
    
        public CommonService(ApplicationDbContext applicationDbContext)
        {
            _applicationDbContext = applicationDbContext;
            connectionString = _applicationDbContext.Database.GetDbConnection().ConnectionString;
        }
    

提交回复
热议问题