diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.BuilderExtensions.cs b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.BuilderExtensions.cs
index 668f090..c12ae54 100644
--- a/src/DotNetCore.CAP.EntityFrameworkCore/CAP.BuilderExtensions.cs
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/CAP.BuilderExtensions.cs
@@ -28,6 +28,7 @@ namespace Microsoft.Extensions.DependencyInjection
builder.Services.Configure(actionOptions);
var sqlServerOptions = new SqlServerOptions();
+ sqlServerOptions.DbContextType = typeof(TContext);
actionOptions(sqlServerOptions);
builder.Services.AddSingleton(sqlServerOptions);
@@ -44,6 +45,6 @@ namespace Microsoft.Extensions.DependencyInjection
return builder;
}
-
+
}
}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/CapDbContext.cs b/src/DotNetCore.CAP.EntityFrameworkCore/CapDbContext.cs
index 3b861d1..882e742 100644
--- a/src/DotNetCore.CAP.EntityFrameworkCore/CapDbContext.cs
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/CapDbContext.cs
@@ -28,8 +28,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
///
/// Gets or sets the of Messages.
///
- public DbSet CapSentMessages { get; set; }
-
+ public DbSet CapSentMessages { get; set; }
public DbSet CapQueue { get; set; }
@@ -48,6 +47,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
///
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
+ //_sqlServerOptions = new SqlServerOptions();
modelBuilder.HasDefaultSchema(_sqlServerOptions.Schema);
modelBuilder.Entity(b =>
@@ -67,6 +67,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
+ // optionsBuilder.UseSqlServer("Server=192.168.2.206;Initial Catalog=Test;User Id=cmswuliu;Password=h7xY81agBn*Veiu3;MultipleActiveResultSets=True");
}
}
}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisherExtensions.cs b/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisherExtensions.cs
index ad9d5be..0d4a4b6 100644
--- a/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisherExtensions.cs
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/CapPublisherExtensions.cs
@@ -32,7 +32,7 @@ namespace DotNetCore.CAP
}
- public static async Task Publish(this ICapPublisher publisher, string topic, string content, IDbConnection connection,IDbTransaction transaction)
+ public static async Task Publish(this ICapPublisher publisher, string topic, string content, IDbConnection connection, IDbTransaction transaction)
{
var message = new CapSentMessage
{
diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/EFStorageConnection.cs b/src/DotNetCore.CAP.EntityFrameworkCore/EFStorageConnection.cs
index f996028..b8e278e 100644
--- a/src/DotNetCore.CAP.EntityFrameworkCore/EFStorageConnection.cs
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/EFStorageConnection.cs
@@ -108,14 +108,14 @@ WHERE StateName = '{StatusName.Enqueued}'";
private async Task FetchNextMessageCoreAsync(string sql, object args = null)
{
- FetchedMessage fetchedJob = null;
+ FetchedMessage fetchedMessage = null;
var connection = _context.GetDbConnection();
var transaction = _context.Database.CurrentTransaction;
transaction = transaction ?? await _context.Database.BeginTransactionAsync(IsolationLevel.ReadCommitted);
try
{
- fetchedJob =
+ fetchedMessage =
(await connection.QueryAsync(sql, args, transaction.GetDbTransaction()))
.FirstOrDefault();
}
@@ -125,7 +125,7 @@ WHERE StateName = '{StatusName.Enqueued}'";
throw;
}
- if (fetchedJob == null)
+ if (fetchedMessage == null)
{
transaction.Rollback();
transaction.Dispose();
@@ -133,8 +133,8 @@ WHERE StateName = '{StatusName.Enqueued}'";
}
return new EFFetchedMessage(
- fetchedJob.MessageId,
- fetchedJob.Type,
+ fetchedMessage.MessageId,
+ fetchedMessage.Type,
connection,
transaction);
}
diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerOptions.cs b/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerOptions.cs
index 4f6532e..03aebd3 100644
--- a/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerOptions.cs
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/SqlServerOptions.cs
@@ -31,5 +31,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
/// Default is .
///
public string MigrationsHistoryTableName { get; set; } = DefaultMigrationsHistoryTableName;
+
+ public Type DbContextType { get; set; }
}
}