• abp第二篇《实现增删改的功能》


    一、关掉“多租户”的设置(我现在用不到,如果需要到时候再开启)

    在Core的 ******CoreModule.cs里,把MultiTenancyEnabled里的值改为false就可以了。

     二、建立实体

    public class SupplierCompanyInfo : FullAuditedEntity<Guid>
        {
            /// <summary>
            /// 公司名称
            /// </summary>
            [Required]
            public string Name { get; set; }
            /// <summary>
            /// 联系电话
            /// </summary>
            public string ContactNumber { get; set; }
            /// <summary>
            /// 地址
            /// </summary>
            [MaxLength(200)]
            public string Address { get; set; }
            /// <summary>
            /// 公司邮箱
            /// </summary>
            [EmailAddress]
            public string Email { get; set; }
            /// <summary>
            /// 备注
            /// </summary>
            public string Remarks { get; set; }
        }

     FullAuditedEntity<Guid>表示,这个类除了自有属性以后,他会自动加上:创建时间等等属性

     建立实体与数据库关联

    namespace Purchase.EntityFrameworkCore
    {
        public class PurchaseDbContext : AbpZeroDbContext<Tenant, Role, User, PurchaseDbContext>
        {
            /* Define a DbSet for each entity of the application */
    
            public PurchaseDbContext(DbContextOptions<PurchaseDbContext> options)
                : base(options)
            {
            }
            public DbSet<SupplierCompanyInfo> SupplierCompanys { get; set; }
            protected override void OnModelCreating(ModelBuilder modelBuilder)
            {
                modelBuilder.Entity<SupplierCompany>().ToTable("SupplierCompanyInfo");
    
                base.OnModelCreating(modelBuilder);
            }
        }
    }

     三、生成到数据库

    在“程序包管理控制台”里执行 add-migration addSupplierCompantEntity

    在“程序包管理控制台”里执行 update-database

  • 相关阅读:
    php静态调用非静态方法
    phalcon 框架3.0更新时报错
    centos7.5更换docker-ce镜像源
    腾讯云更换镜像源遇到的坑
    php cli模式下调试
    审查php.ini自动分析程序
    docker WARNING: IPv4 forwarding is disabled. Networking will not work.
    git常用命令,制作缩写命令
    学习GRPC(一) 简单实现
    mac与linux服务器之间使用ssh互通有无
  • 原文地址:https://www.cnblogs.com/wjx-blog/p/12441340.html
Copyright © 2020-2023  润新知