ノーコードでクラウド上のデータとの連携を実現。
詳細はこちら →Bugzilla Data Provider の30日間無償トライアルをダウンロード
30日間の無償トライアルへ製品の詳細
Bugzilla ADO.NET Provider 相談したいBugzilla のBugs、Branches、Users データに連携する.NET アプリケーションを素早く、簡単に開発できる便利なドライバー。
CData
こんにちは!ウェブ担当の加藤です。マーケ関連のデータ分析や整備もやっています。
Entity Framework はobject-relational mapping フレームワークで、データをオブジェクトとして扱うために使われます。Visual Studio のADO.NET Entity Data Model ウィザードを実行するとEntity Model を作成できますが、このモデルファーストアプローチでは、データソースに変更があった場合やエンティティ操作をより制御したい場合は不都合があります。この記事では、CData ADO.NET Provider を使いコードファーストアプローチでBugzilla にアクセスします。
Bugzilla アカウントには以下の接続プロパティで接続します:
<configuration>
... <connectionStrings>
<add name="BugzillaContext" connectionString="Offline=False;Url=http://yourdomain/Bugzilla;APIKey=abc123;" providerName="System.Data.CData.Bugzilla" />
</connectionStrings>
<entityFramework>
<providers>
... <provider invariantName="System.Data.CData.Bugzilla" type="System.Data.CData.Bugzilla.BugzillaProviderServices, System.Data.CData.Bugzilla.Entities.EF6" />
</providers>
<entityFramework>
</configuration>
</code>
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
class BugzillaContext :DbContext {
public BugzillaContext() { }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { // To remove the requests to the Migration History table
Database.SetInitializer<BugzillaContext>(null); // To remove the plural names modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
public class Bugs {
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public System.String Id { get; set; }
public System.String Id { get; set; }
}
public class BugsMap :EntityTypeConfiguration<Bugs> {
public BugsMap() {
this.ToTable("Bugs");
this.HasKey(Bugs => Bugs.Id);
this.Property(Bugs => Bugs.Id);
}
}
public DbSet<Bugs> Bugs { set; get; }
BugzillaContext context = new BugzillaContext();
context.Configuration.UseDatabaseNullSemantics = true;
var query = from line in context.Bugs select line;