![]() |
VOOZH | about |
Microsoft Entity Framework serves as an object-relational mapping framework for working with data represented as objects. Although Visual Studio offers the ADO.NET Entity Data Model wizard to automatically generate the Entity Model, this model-first approach may present challenges when your data source undergoes changes or when you require greater control over entity operations. In this article, we will delve into the code-first approach for accessing HCL Domino data through the CData ADO.NET Provider, providing you with more flexibility and control.
Modify the App.config file in the project to add a reference to the HCL Domino Entity Framework 6 assembly and the connection string.
To connect to Domino data, set the following properties:
Domino supports authenticating via login credentials or an Entra ID (formerly Azure AD) OAuth application:
To authenticate with login credentials, set the following properties:
The driver uses the login credentials to automatically perform an OAuth token exchange.
This authentication method uses Entra ID (formerly Azure AD) as an IdP to obtain a JWT token. You need to create a custom OAuth application in Entra ID (formerly Azure AD) and configure it as an IdP. To do so, follow the instructions in the Help documentation. Then set the following properties:
The tenant ID is the same as the directory ID shown in the Azure Portal's Entra ID (formerly Azure AD) > Properties page.
<configuration> ... <connectionStrings> <add name="DominoContext" connectionString="Offline=False;Server=https://domino.corp.com;AuthScheme=OAuthPassword;User=my_domino_user;Password=my_domino_password;" providerName="System.Data.CData.Domino" /> </connectionStrings> <entityFramework> <providers> ... <provider invariantName="System.Data.CData.Domino" type="System.Data.CData.Domino.DominoProviderServices, System.Data.CData.Domino.Entities.EF6" /> </providers> <entityFramework> </configuration> </code>
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
class DominoContext : DbContext {
public DominoContext() { }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// To remove the requests to the Migration History table
Database.SetInitializer<DominoContext>(null);
// To remove the plural names
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
[System.ComponentModel.DataAnnotations.Schema.Table("ByName")]
public class ByName {
[System.ComponentModel.DataAnnotations.Key]
public System.String Name { get; set; }
public System.String Address { get; set; }
}
public DbSet<ByName> ByName { set; get; }
DominoContext context = new DominoContext(); context.Configuration.UseDatabaseNullSemantics = true; var query = from line in context.ByName select line;
Download a free trial of the HCL Domino Data Provider to get started:
Download NowLearn more:
👁 HCL Domino IconRapidly create and deploy powerful .NET applications that integrate with HCL Domino.