![]() |
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 Kintone 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 Kintone Entity Framework 6 assembly and the connection string.
In addition to the authentication values, set the following parameters to connect to and retrieve data from Kintone:
Kintone supports the following authentication methods.
You must set the following to authenticate:
If the basic authentication security feature is set on the domain, supply the additional login credentials with BasicAuthUser and BasicAuthPassword. Basic authentication requires these credentials in addition to User and Password.
Instead of basic authentication, you can specify a client certificate to authenticate. Set SSLClientCert, SSLClientCertType, SSLClientCertSubject, and SSLClientCertPassword. Additionally, set User and Password to your login credentials.
<configuration> ... <connectionStrings> <add name="KintoneContext" connectionString="Offline=False;User=myuseraccount;Password=mypassword;Url=http://subdomain.domain.com;GuestSpaceId=myspaceid" providerName="System.Data.CData.Kintone" /> </connectionStrings> <entityFramework> <providers> ... <provider invariantName="System.Data.CData.Kintone" type="System.Data.CData.Kintone.KintoneProviderServices, System.Data.CData.Kintone.Entities.EF6" /> </providers> <entityFramework> </configuration> </code>
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
class KintoneContext : DbContext {
public KintoneContext() { }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// To remove the requests to the Migration History table
Database.SetInitializer<KintoneContext>(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("Comments")]
public class Comments {
[System.ComponentModel.DataAnnotations.Key]
public System.String CreatorName { get; set; }
public System.String Text { get; set; }
}
public DbSet<Comments> Comments { set; get; }
KintoneContext context = new KintoneContext(); context.Configuration.UseDatabaseNullSemantics = true; var query = from line in context.Comments select line;
Download a free trial of the Kintone Data Provider to get started:
Download NowLearn more:
👁 Kintone IconRapidly create and deploy powerful .NET applications that integrate with Kintone applications and databases.