Activities of "yinlong"

anybody here?

I want to expand OrganizationUnit ,like appuser but,debug error the error message:

entity

using HF.EducationCloud.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Identity;
using Volo.Abp.MultiTenancy;

namespace HF.EducationCloud.OrganizationUnits
{
    /// <summary>
    /// 组织扩展表
    /// </summary>
   public class AppOrganizationUnit : FullAuditedAggregateRoot<Guid>, IMultiTenant
    {
        public virtual Guid? TenantId { get; private set; }
        public virtual string DisplayName { get; set; }
        public virtual Guid? ParentId { get;  set; }
        /// <summary>
        /// 机构代码
        /// </summary>
        public string OrgCode { get; set; }
        public string OrgPic { get; set; }

        /// <summary>
        /// 机构属性:机构类别 0:小学 1:初中 2:高中 3:完中 4:机构 5:教学点 6:九年一贯制 7: 十二年一贯制
        /// </summary>
        public OrgCage OrgCage { get; set; }
        /// <summary>
        /// 省编码
        /// </summary>
        public string ProvinceCode { get; set; }

        /// <summary>
        /// 市编码
        /// </summary>
        public string CityCode { get; set; }

        /// <summary>
        /// 区编码
        /// </summary>
        public string AreaCode { get; set; }

        /// <summary>
        /// 机构类型:1:国家2:区域3:市4:区
        /// </summary>
        public OrgType OrgType { get; set; }
    }
}

EducationCloudDbContext

using Volo.Abp.EntityFrameworkCore.Modeling;
using Microsoft.EntityFrameworkCore;
using HF.EducationCloud.Teachers;
using HF.EducationCloud.Students;
using HF.EducationCloud.ClassManages;
using HF.EducationCloud.Users;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Users.EntityFrameworkCore;
using HF.EducationCloud.Schools;
using Volo.Abp.ObjectExtending;
using HF.EducationCloud.OrganizationUnits;
using Volo.Abp.Identity.EntityFrameworkCore;

namespace HF.EducationCloud.EntityFrameworkCore
{
    /* This is your actual DbContext used on runtime.
     * It includes only your entities.
     * It does not include entities of the used modules, because each module has already
     * its own DbContext class. If you want to share some database tables with the used modules,
     * just create a structure like done for AppUser.
     *
     * Don't use this DbContext for database migrations since it does not contain tables of the
     * used modules (as explained above). See EducationCloudMigrationsDbContext for migrations.
     */
    [ConnectionStringName("Default")]
    public class EducationCloudDbContext : AbpDbContext<EducationCloudDbContext>
    {
    
        public virtual DbSet<AppUser> Users { get; set; }

        public virtual DbSet<AppOrganizationUnit> AppOrganizationUnit { get; set; }

        /* Add DbSet properties for your Aggregate Roots / Entities here.
         * Also map them inside EducationCloudDbContextModelCreatingExtensions.ConfigureEducationCloud
         */

        public DbSet<Teacher> Teachers { get; set; }
        public DbSet<Student> Students { get; set; }
        public DbSet<ClassManage> ClassManages { get; set; }

        public virtual DbSet<ClassBindUser> ClassBindUser { get; set; }
        public virtual DbSet<ClassInfo> ClassInfo { get; set; }

     
        public EducationCloudDbContext(DbContextOptions<EducationCloudDbContext> options)
            : base(options)
        {

        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            /* Configure the shared tables (with included modules) here */
            
            builder.Entity<AppUser>(b =>
            {
                b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users"); //Sharing the same table "AbpUsers" with the IdentityUser

                b.ConfigureByConvention();
                b.ConfigureAbpUser();

                /* Configure mappings for your additional properties.
                 * Also see the EducationCloudEfCoreEntityExtensionMappings class.
                 */
            });


            builder.Entity<AppOrganizationUnit>(b =>
            {
                b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "OrganizationUnits");
               // b.ConfigureByConvention();
             
                //b.ConfigureExtraProperties();
                ////b.Ignore(x => x.ExtraProperties);
                //b.Property(x => x.OrgCode);
                //b.HasMany<OrganizationUnitRole>();
            });
            // add this..
            //builder.Entity<OrganizationUnit>(b =>
            //{
            //    b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "OrganizationUnits");

            //    b.ConfigureByConvention();

            //    b.Property(ou => ou.Code).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxCodeLength)
            //        .HasColumnName(nameof(OrganizationUnit.Code));
            //    b.Property(ou => ou.DisplayName).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxDisplayNameLength)
            //        .HasColumnName(nameof(OrganizationUnit.DisplayName));

            //    b.HasMany<OrganizationUnit>().WithOne().HasForeignKey(ou => ou.ParentId);
            //    b.HasMany(ou => ou.Roles).WithOne().HasForeignKey(our => our.OrganizationUnitId).IsRequired();

            //    b.HasIndex(ou => ou.Code);
            //});

            //builder.Ignore<OrganizationUnitRole>();
            
            /* Configure your own tables/entities inside the ConfigureEducationCloud method */

            builder.ConfigureEducationCloud();
        }
    }
}

EducationCloudEfCoreEntityExtensionMappings

using HF.EducationCloud.OrganizationUnits;
using HF.EducationCloud.Users;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;

namespace HF.EducationCloud.EntityFrameworkCore
{
    public static class EducationCloudEfCoreEntityExtensionMappings
    {
        private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();

        public static void Configure()
        {
            EducationCloudGlobalFeatureConfigurator.Configure();
            EducationCloudModuleExtensionConfigurator.Configure();

            OneTimeRunner.Run(() =>
            {
                /* You can configure extra properties for the
                 * entities defined in the modules used by your application.
                 *
                 * This class can be used to map these extra properties to table fields in the database.
                 *
                 * USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING.
                 * USE EducationCloudModuleExtensionConfigurator CLASS (in the Domain.Shared project)
                 * FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES
                 *
                 * Example: Map a property to a table field:

                     ObjectExtensionManager.Instance
                         .MapEfCoreProperty<IdentityUser, string>(
                             "MyProperty",
                             (entityBuilder, propertyBuilder) =>
                             {
                                 propertyBuilder.HasMaxLength(128);
                             }
                         );

                 * See the documentation for more:
                 * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
                 */

                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, string>(
                nameof(AppOrganizationUnit.OrgCode),
                (entityBuilder, propertyBuilder) =>
                {
                    propertyBuilder.HasMaxLength(255);
                });

                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, string>(
              nameof(AppOrganizationUnit.OrgPic),
              (entityBuilder, propertyBuilder) =>
              {
                  propertyBuilder.HasMaxLength(255);
              });
                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, int>(
                          nameof(AppOrganizationUnit.OrgCage),
                          (entityBuilder, propertyBuilder) =>
                          {
                              propertyBuilder.HasMaxLength(255);
                          });
                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, string>(
                        nameof(AppOrganizationUnit.ProvinceCode),
                        (entityBuilder, propertyBuilder) =>
                        {
                            propertyBuilder.HasMaxLength(255);
                        });

                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, string>(
                      nameof(AppOrganizationUnit.CityCode),
                      (entityBuilder, propertyBuilder) =>
                      {
                          propertyBuilder.HasMaxLength(255);
                      });
                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, string>(
                    nameof(AppOrganizationUnit.AreaCode),
                    (entityBuilder, propertyBuilder) =>
                    {
                        propertyBuilder.HasMaxLength(255);
                    });
                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, int>(
                        nameof(AppOrganizationUnit.OrgType),
                        (entityBuilder, propertyBuilder) =>
                        {
                            propertyBuilder.HasMaxLength(255);
                        });
                ObjectExtensionManager.Instance.MapEfCoreProperty<OrganizationUnit, string>(
                       nameof(AppOrganizationUnit.ExtraProperties),
                       (entityBuilder, propertyBuilder) =>
                       {
                           propertyBuilder.HasMaxLength(255);
                       });
                ObjectExtensionManager.Instance.MapEfCoreProperty<AppOrganizationUnit, string>(
                     nameof(OrganizationUnit.ExtraProperties),
                     (entityBuilder, propertyBuilder) =>
                     {
                         propertyBuilder.HasMaxLength(255);
                     });
            });
        }
    }
}

Showing 1 to 2 of 2 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35