![]() |
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 Oracle Eloqua Reporting 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 Oracle Eloqua Reporting Entity Framework 6 assembly and the connection string.
Oracle Eloqua Reporting supports the following authentication methods:
To perform authentication with a user and password, specify these properties:
To authenticate with the OAuth code grant flow, you must set AuthScheme to OAuth and create a custom OAuth application. For information about how to create a custom OAuth application, see the Help documentation.
Then set the following properties:
When you connect, the driver opens Oracle Eloqua Reporting's OAuth endpoint in your default browser. Log in and grant permissions to the application. When the access token expires, the driver refreshes it automatically.
With the OAuth password grant flow, you can use your OAuth application's credentials alongside your user credentials to authenticate without the need to grant permission manually via a browser prompt. You must create an OAuth app (see the Help documentation) to use this authentication method.
Set the following properties:
<configuration> ... <connectionStrings> <add name="OracleEloquaReportingContext" connectionString="Offline=False;AuthScheme=Basic;User=user;Password=password;Company=MyCompany;" providerName="System.Data.CData.OracleEloquaReporting" /> </connectionStrings> <entityFramework> <providers> ... <provider invariantName="System.Data.CData.OracleEloquaReporting" type="System.Data.CData.OracleEloquaReporting.OracleEloquaReportingProviderServices, System.Data.CData.OracleEloquaReporting.Entities.EF6" /> </providers> <entityFramework> </configuration> </code>
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
class OracleEloquaReportingContext : DbContext {
public OracleEloquaReportingContext() { }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// To remove the requests to the Migration History table
Database.SetInitializer<OracleEloquaReportingContext>(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("")]
public class {
[System.ComponentModel.DataAnnotations.Key]
public System.String { get; set; }
public System.String { get; set; }
}
public DbSet<> { set; get; }
OracleEloquaReportingContext context = new OracleEloquaReportingContext(); context.Configuration.UseDatabaseNullSemantics = true; var query = from line in context. select line;
Download a free trial of the Oracle Eloqua Reporting Data Provider to get started:
Download NowLearn more:
👁 Oracle Eloqua Reporting IconRapidly create and deploy powerful .NET applications that integrate with Oracle Eloqua Reporting.