Open Closed

Dataseeding a Many to Many item not working? #5974


User avatar
0
SuperBeastX3 created

ABP Framework version: v7.3.3 UI Type: MVC Database System: EF Core Tiered (for MVC) or Auth Server Separated (for Angular): tiered

I am trying to dataseed an object with a many to many collection. I create the collection items first, and then try to use those ids on insert of the many to many, but it never actually saves them. The underlying checks SetAssetCategoriesAsync don't see them yet because they are not in the database, so it doesn't pull any to save.

assetCategoryList.Add(await _assetCategoryManager.CreateAsync("Corporate Laptop", "Corporate Laptop", true));
assetCategoryList.Add(await _assetCategoryManager.CreateAsync("Developer Laptop", "Developer Laptop", true));

This next line creates the my asset taxonomy item, but doesn't add the newly created asset categories.

assetTaxonomy = await _assetTaxonomyManager.CreateAsync(assetCategoryList.Select(e => e.Id).ToList(), "Asset Taxonomy", "Asset Taxonomy Description"); ;

In the SetAssetCategoriesAsync (created by abp suite), no categories are found:

var query = (await _assetCategoryRepository.GetQueryableAsync())
    .Where(x => assetCategoryIds.Contains(x.Id))
    .Select(x => x.Id);
var assetCategoryIdsInDb = await AsyncExecuter.ToListAsync(query);
if (!assetCategoryIdsInDb.Any())
{
    return;
}

Please advise, thanks!


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

    Hi,

    Could you use the abp suite to create a new project to reproduce the problem and share it with me? my email is shiwei.liang@volosoft.com.

    I will check it. thanks.

  • User Avatar
    0
    SuperBeastX3 created

    A zipped sample is 242Mb, I can't email that. Do you have a place I can copy it to?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can upload to google drive or onedrive and share the link with me.

  • User Avatar
    0
    SuperBeastX3 created

    See if this link works for you: https://1drv.ms/u/s----------------?e=FhNSL1

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You need to save change first.

  • User Avatar
    0
    SuperBeastX3 created

    Ah, I see. That worked. Thanks!

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07