ADO.NET Provider for FHIR

Build 25.0.9539

EF Core ASP.NET Application

Registering the Context with Dependency Injection

To enable dependency injection for FHIRContext, you must register it with the service container. In newer ASP.NET Core projects (using the minimal hosting model), this is done in Program.cs. In older projects, the code may go in Startup.cs.

using MySolutionName.Models;
using Microsoft.EntityFrameworkCore;

var connection = @"URL=http://test.fhir.org/r4b/;ConnectionType=Generic;ContentType=JSON;AuthScheme=None;";
builder.Services.AddDbContext<FHIRContext>(options =>
    options.UseFHIR(connection));

Creating a Controller and Views

To create a controller and views for your web app, follow these steps:

  1. Right-click the Controllers folder in the Solution Explorer and select Add -> Controller...
  2. Choose MVC Controller with views, using Entity Framework, and then click Add.
  3. Set the Model Class to the class corresponding to your table or view and set the Data context class to FHIRContext.
  4. Click Add. Take note of the controller name.

Running Your Application

Once controller and views have been setup, you can launch your app by selecting Debug -> Start Without Debugging. Your browser opens automatically.

To view your data, navigate to <base URL>/<controller name without the "Controller" suffix>

For example, a controller named AccountController hosted on port 5001 would use the URL https://localhost:5001/Account.

Copyright (c) 2026 CData Software, Inc. - All rights reserved.
Build 25.0.9539