Open Closed

Use FmFileDescriptors as a navigation property #5933


User avatar
0
ianbaddock created
  • ABP Framework version: v7.3.2
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

I have included the file management module in my solution and I would like to create a table for Media which has a navigation property to the files stored in FmFileDescriptors. My solution would allow for upload reports/images/videos which are stored in the files table, but I am creating a gallery on top of the files using the Media table as my gallery source. I would prefer not to use the files tables directly as I need to make many modifications to the schema as well as have other related tables for meta data (EXIF data) and tagging data.


5 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    May I ask what blocked you?

  • User Avatar
    0
    ianbaddock created

    I am not sure how to add the navigation property to the file management entities. I cannot see them in the list.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try:

    ...
    [ReplaceDbContext(typeof(IFileManagementDbContext))]
    public class YourDbcontext: ..... IFileManagementDbContext
    {
        .....
        
        public DbSet<FileMataData> FileMataData {get; set;}
       
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
        
            .....
             
            builder.Entity<FileMataData>(b =>
            {
                b.ToTable(MyProjectNameConsts.DbTablePrefix + "FileMataData", MyProjectNameConsts.DbSchema);
                b.HasOne(e => e.File).WithOne();
                b.ConfigureByConvention(); //auto configure for the base class props
            });
        }
    }
    
    public class FileMataData: Entity<Guid>
    {
       public Guid FileId { get; set; }
       public FileDescriptor File { get; set;}
       
       .....
    }
    
  • User Avatar
    0
    ianbaddock created

    aaah I assume you have to do it without using the abp suite?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Yes

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11