schangxiang@126.com
2025-05-21 fa365d77dfa1d6619774a790e424e98dac849457
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using CMS.Plugin.PipeLineLems.EntityFrameworkCore.Extensions;
using CMS.Plugin.PipeLineLems.Domain;
using CMS.Plugin.PipeLineLems.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
 
namespace CMS.Plugin.PipeLineLems.PostgreSql;
 
/// <summary>
/// 数据库上下文
/// </summary>
[ConnectionStringName(CMSPluginDbProperties.ConnectionStringName)]
public class CMSPluginDbContext : AbpDbContext<CMSPluginDbContext>, ICMSPluginDbContext
{
    /* Add DbSet properties for your Aggregate Roots / Entities here. */
 
    /// <summary>
    /// Initializes a new instance of the <see cref="CMSPluginDbContext"/> class.
    /// </summary>
    /// <param name="options">The options.</param>
    public CMSPluginDbContext(DbContextOptions<CMSPluginDbContext> options)
        : base(options)
    {
    }
 
    /// <inheritdoc />
    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
 
        /* Include modules to your migration db context */
 
        builder.ConfigureMyTestEntityName();
 
        /* Configure your own tables/entities inside here */
 
        //builder.Entity<YourEntity>(b =>
        //{
        //    b.ToTable(CMSPluginDbProperties.DbTablePrefix + "YourEntities", CMSPluginDbProperties.DbSchema);
        //    b.ConfigureByConvention(); //auto configure for the base class props
        //    //...
        //});
 
        builder.TryConfigureObjectExtensions<CMSPluginDbContext>();
    }
}