Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate how to choose DbContext per request #1535

Closed
wants to merge 1 commit into from

Conversation

bkoelman
Copy link
Member

@bkoelman bkoelman commented Apr 23, 2024

This PR answers the question at #1532.
Note this only works properly if the EF Core models (not the database tables) are identical.

Output:

GET http://localhost:14141/api/people?include=books
{
  "links": {
    "self": "/api/people?include=books"
  },
  "errors": [
    {
      "id": "f2b81ea6-dac4-48cc-a1f1-f5eb402eb140",
      "status": "400",
      "title": "The 'dbType' query string parameter is missing or invalid.",
    }
  ],
  "included": []
}
GET http://localhost:14141/api/people?include=books&dbType=sqlite

image

GET http://localhost:14141/api/people?include=books&dbType=postgresql

image

@bkoelman bkoelman changed the title Demonstrate how to choose DbContext at runtime Demonstrate how to choose DbContext per request Apr 23, 2024
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.79%. Comparing base (9c51fe3) to head (bcaf5aa).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1535   +/-   ##
=======================================
  Coverage   90.79%   90.79%           
=======================================
  Files         346      346           
  Lines       11063    11063           
  Branches     1814     1814           
=======================================
  Hits        10045    10045           
  Misses        669      669           
  Partials      349      349           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Note this only works properly if the EF Core models (not the database tables) are identical.
@bkoelman bkoelman closed this Apr 23, 2024
@bkoelman bkoelman deleted the answer-issue-1532 branch April 23, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant