* Created AzureDataModel
* Created Hangfire API
This commit is contained in:
40
AzureDataModel/AzureDbContext.cs
Normal file
40
AzureDataModel/AzureDbContext.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using TaskScheduler = AzureDataModel.Entities.TaskScheduler;
|
||||
|
||||
namespace AzureDataModel;
|
||||
|
||||
public class AzureDbContext : DbContext
|
||||
{
|
||||
public AzureDbContext(DbContextOptions<AzureDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
|
||||
var connectionString = configuration.GetConnectionString("AzureConnection");
|
||||
optionsBuilder.UseAzureSql(connectionString, options => options.CommandTimeout(300));
|
||||
}
|
||||
|
||||
public DbSet<TaskScheduler> TaskSchedulers { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<TaskScheduler>()
|
||||
.HasKey(e => e.Id);
|
||||
|
||||
modelBuilder.Entity<TaskScheduler>()
|
||||
.Property(e => e.RowPointer)
|
||||
.HasDefaultValueSql("newid()");
|
||||
|
||||
modelBuilder.Entity<TaskScheduler>()
|
||||
.Property(e => e.CreateDate)
|
||||
.HasDefaultValueSql("getdate()");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user