Base solution for your next web application
Open Closed

Access ConnectionString or SqlConnection inside an AppServic #1577


User avatar
0
eu11111 created

Hey. I am trying to run a bulk insert inside the database. My problem is that I need to us a SqlConnection to do so, inside an AppService. Should I use the Core layer instead?

Anyway, is there a way of accessing th ConnectionString from appsettings.json inside the Web project from another project? Or getting a SqlConnection object from the dbContext or something related?

Thanks in advance


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    You can try to create a custom repository (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration#DocCustomRepositoryMethods">http://www.aspnetboilerplate.com/Pages/ ... oryMethods</a>) and use Context.Database to directly run SQL commands.