diff --git a/samples/Sample.Kafka/AppDbContext.cs b/samples/Sample.Kafka/AppDbContext.cs index e929396..fbc9da5 100644 --- a/samples/Sample.Kafka/AppDbContext.cs +++ b/samples/Sample.Kafka/AppDbContext.cs @@ -10,6 +10,16 @@ namespace Sample.Kafka { public class AppDbContext : DbContext { + public DbSet Messages { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { + optionsBuilder.UseSqlServer("Server=192.168.2.206;Initial Catalog=Test;User Id=cmswuliu;Password=h7xY81agBn*Veiu3;MultipleActiveResultSets=True"); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) { + modelBuilder.Entity().Property(x => x.RowVersion).IsConcurrencyToken(); + base.OnModelCreating(modelBuilder); + } } } diff --git a/samples/Sample.Kafka/Controllers/ValuesController.cs b/samples/Sample.Kafka/Controllers/ValuesController.cs index f67e51b..88ae91f 100644 --- a/samples/Sample.Kafka/Controllers/ValuesController.cs +++ b/samples/Sample.Kafka/Controllers/ValuesController.cs @@ -1,8 +1,8 @@ using System; using System.Threading.Tasks; +using Cap.Consistency; using Cap.Consistency.Consumer; using Cap.Consistency.Kafka; -using Cap.Consistency.Producer; using Microsoft.AspNetCore.Mvc; namespace Sample.Kafka.Controllers diff --git a/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.Designer.cs b/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.Designer.cs new file mode 100644 index 0000000..afa67cd --- /dev/null +++ b/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.Designer.cs @@ -0,0 +1,45 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Sample.Kafka; +using Cap.Consistency.Infrastructure; + +namespace Sample.Kafka.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20170622091105_CreateInit")] + partial class CreateInit + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.2") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Cap.Consistency.Infrastructure.ConsistencyMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Payload"); + + b.Property("RowVersion") + .IsConcurrencyToken(); + + b.Property("SendTime"); + + b.Property("Status"); + + b.Property("Topic"); + + b.Property("UpdateTime"); + + b.HasKey("Id"); + + b.ToTable("Messages"); + }); + } + } +} diff --git a/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.cs b/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.cs new file mode 100644 index 0000000..b67d9b9 --- /dev/null +++ b/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Sample.Kafka.Migrations +{ + public partial class CreateInit : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Messages", + columns: table => new + { + Id = table.Column(nullable: false), + Payload = table.Column(nullable: true), + RowVersion = table.Column(nullable: true), + SendTime = table.Column(nullable: false), + Status = table.Column(nullable: false), + Topic = table.Column(nullable: true), + UpdateTime = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Messages", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Messages"); + } + } +} diff --git a/samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs b/samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..6150414 --- /dev/null +++ b/samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,44 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Sample.Kafka; +using Cap.Consistency.Infrastructure; + +namespace Sample.Kafka.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.2") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Cap.Consistency.Infrastructure.ConsistencyMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Payload"); + + b.Property("RowVersion") + .IsConcurrencyToken(); + + b.Property("SendTime"); + + b.Property("Status"); + + b.Property("Topic"); + + b.Property("UpdateTime"); + + b.HasKey("Id"); + + b.ToTable("Messages"); + }); + } + } +} diff --git a/samples/Sample.Kafka/Program.cs b/samples/Sample.Kafka/Program.cs index a22c3a8..659106f 100644 --- a/samples/Sample.Kafka/Program.cs +++ b/samples/Sample.Kafka/Program.cs @@ -12,7 +12,6 @@ namespace Sample.Kafka .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() - .UseApplicationInsights() .Build(); host.Run(); diff --git a/samples/Sample.Kafka/Sample.Kafka.csproj b/samples/Sample.Kafka/Sample.Kafka.csproj index f663107..783a746 100644 --- a/samples/Sample.Kafka/Sample.Kafka.csproj +++ b/samples/Sample.Kafka/Sample.Kafka.csproj @@ -5,18 +5,22 @@ + + - - + + + +