@@ -10,6 +10,16 @@ namespace Sample.Kafka | |||||
{ | { | ||||
public class AppDbContext : DbContext | public class AppDbContext : DbContext | ||||
{ | { | ||||
public DbSet<ConsistencyMessage> Messages { get; set; } | public DbSet<ConsistencyMessage> 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<ConsistencyMessage>().Property(x => x.RowVersion).IsConcurrencyToken(); | |||||
base.OnModelCreating(modelBuilder); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,8 +1,8 @@ | |||||
using System; | using System; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Cap.Consistency; | |||||
using Cap.Consistency.Consumer; | using Cap.Consistency.Consumer; | ||||
using Cap.Consistency.Kafka; | using Cap.Consistency.Kafka; | ||||
using Cap.Consistency.Producer; | |||||
using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||
namespace Sample.Kafka.Controllers | namespace Sample.Kafka.Controllers | ||||
@@ -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<string>("Id") | |||||
.ValueGeneratedOnAdd(); | |||||
b.Property<string>("Payload"); | |||||
b.Property<byte[]>("RowVersion") | |||||
.IsConcurrencyToken(); | |||||
b.Property<DateTime>("SendTime"); | |||||
b.Property<int>("Status"); | |||||
b.Property<string>("Topic"); | |||||
b.Property<DateTime?>("UpdateTime"); | |||||
b.HasKey("Id"); | |||||
b.ToTable("Messages"); | |||||
}); | |||||
} | |||||
} | |||||
} |
@@ -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<string>(nullable: false), | |||||
Payload = table.Column<string>(nullable: true), | |||||
RowVersion = table.Column<byte[]>(nullable: true), | |||||
SendTime = table.Column<DateTime>(nullable: false), | |||||
Status = table.Column<int>(nullable: false), | |||||
Topic = table.Column<string>(nullable: true), | |||||
UpdateTime = table.Column<DateTime>(nullable: true) | |||||
}, | |||||
constraints: table => | |||||
{ | |||||
table.PrimaryKey("PK_Messages", x => x.Id); | |||||
}); | |||||
} | |||||
protected override void Down(MigrationBuilder migrationBuilder) | |||||
{ | |||||
migrationBuilder.DropTable( | |||||
name: "Messages"); | |||||
} | |||||
} | |||||
} |
@@ -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<string>("Id") | |||||
.ValueGeneratedOnAdd(); | |||||
b.Property<string>("Payload"); | |||||
b.Property<byte[]>("RowVersion") | |||||
.IsConcurrencyToken(); | |||||
b.Property<DateTime>("SendTime"); | |||||
b.Property<int>("Status"); | |||||
b.Property<string>("Topic"); | |||||
b.Property<DateTime?>("UpdateTime"); | |||||
b.HasKey("Id"); | |||||
b.ToTable("Messages"); | |||||
}); | |||||
} | |||||
} | |||||
} |
@@ -12,7 +12,6 @@ namespace Sample.Kafka | |||||
.UseContentRoot(Directory.GetCurrentDirectory()) | .UseContentRoot(Directory.GetCurrentDirectory()) | ||||
.UseIISIntegration() | .UseIISIntegration() | ||||
.UseStartup<Startup>() | .UseStartup<Startup>() | ||||
.UseApplicationInsights() | |||||
.Build(); | .Build(); | ||||
host.Run(); | host.Run(); | ||||
@@ -5,18 +5,22 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<Folder Include="Migrations\" /> | |||||
<Folder Include="Migrations\" /> | |||||
<Folder Include="wwwroot\" /> | <Folder Include="wwwroot\" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" /> | |||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" /> | <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" /> | ||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /> | <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /> | ||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" /> | <PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" /> | ||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" /> | |||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" /> | <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" /> | <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" /> | ||||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\..\src\Cap.Consistency.EntityFrameworkCore\Cap.Consistency.EntityFrameworkCore.csproj" /> | <ProjectReference Include="..\..\src\Cap.Consistency.EntityFrameworkCore\Cap.Consistency.EntityFrameworkCore.csproj" /> | ||||