本記事では CData サポート担当からこんなことを聞かれたらどこを確認すべきか?という観点で、よく頂くお問合せ内容をご紹介します。
記事はこちら →Entity Framework はobject-relational mapping フレームワークで、データをオブジェクトとして扱うために使われます。Visual Studio のADO.NET Entity Data Model ウィザードを実行するとEntity Model を作成できますが、このモデルファーストアプローチでは、データソースに変更があった場合やエンティティ操作をより制御したい場合は不都合があります。この記事では、CData ADO.NET Provider を使いコードファーストアプローチでFinancialForce にアクセスします。
There are several authentication methods available for connecting to FinancialForce: login credentials, SSO, and OAuth.
Set the User and Password to your login credentials. Additionally, set the SecurityToken. By default, the SecurityToken is required, but you can make it optional by allowing a range of trusted IP addresses.
To disable the security token:
To obtain the security token:
If you do not have access to the user name and password or do not want to require them, use the OAuth user consent flow. See the OAuth section in the Help for an authentication guide.
Set UseSandbox to true (false by default) to use a FinancialForce sandbox account. Ensure that you specify a sandbox user name in User.
<configuration>
... <connectionStrings>
<add name="FinancialForceContext" connectionString="Offline=False;User=myUser;Password=myPassword;Security Token=myToken;" providerName="System.Data.CData.FinancialForce" />
</connectionStrings>
<entityFramework>
<providers>
... <provider invariantName="System.Data.CData.FinancialForce" type="System.Data.CData.FinancialForce.FinancialForceProviderServices, System.Data.CData.FinancialForce.Entities.EF6" />
</providers>
<entityFramework>
</configuration>
</code>
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
class FinancialForceContext :DbContext {
public FinancialForceContext() { }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { // To remove the requests to the Migration History table
Database.SetInitializer<FinancialForceContext>(null); // To remove the plural names modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
public class Account {
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public System.String Id { get; set; }
public System.String BillingState { get; set; }
}
public class AccountMap :EntityTypeConfiguration<Account> {
public AccountMap() {
this.ToTable("Account");
this.HasKey(Account => Account.Id);
this.Property(Account => Account.BillingState);
}
}
public DbSet<Account> Account { set; get; }
FinancialForceContext context = new FinancialForceContext();
context.Configuration.UseDatabaseNullSemantics = true;
var query = from line in context.Account select line;