Open Closed

(Bug) ABP Suite generates entity files with invalid refs #9914


User avatar
0
mike3077 created
  • Template: app
  • Created ABP Studio Version: 1.2.2
  • Current ABP Studio Version: 1.2.2
  • Tiered: Yes
  • Multi-Tenancy: Yes
  • UI Framework: blazor-webapp
  • Theme: leptonx
  • Theme Style: system
  • Theme Menu Placement: side
  • Run Install Libs: Yes
  • Database Provider: mongodb
  • Run Db Migrator: Yes
  • Mobile Framework: none
  • Public Website: Yes
  • Social Login: Yes
  • Include Tests: Yes
  • Kubernetes Configuration: Yes
  • Distributed Event Bus: rabbitmq
  • Use Local References: No
  • Optional Modules:
    • GDPR
    • FileManagement
    • TextTemplateManagement
    • LanguageManagement
    • AuditLogging
    • Chat
    • OpenIddictAdmin
  • Selected Languages: English, English (United Kingdom)
  • Default Language: English
  • Create Command: abp new AT1.Core -t app --tiered --ui-framework blazor-webapp --database-provider mongodb --theme leptonx --public-website --without-cms-kit --sample-crud-page --dont-run-bundling -chat -file-management

Using ABP Suite to generate an entity creates files with invalid refs:

MongoDB.Tests\MongoDB\Applications\Tickets\MongoDBTicketsAppServiceTests.cs MongoDB.Tests\MongoDB\Domains\Tickets\TicketRepositoryTests.cs MongoDB.Tests\MongoDB\MongoTestCollection.cs

'MongoTestCollection' does not contain a definition for 'CollectionDefinitionName'

[CollectionDefinition(Name)] public class MongoTestCollection : ICollectionFixture<MongoDbFixture> { public const string Name = "MongoDB Collection"; }

We are reporting this as a bug. Please reset our alloted question count. Thanks!


5 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • The issue you described is related to the test collection naming in the generated MongoDB test files. In the generated MongoTestCollection class, the constant Name is used for the collection definition, but the test classes are likely referencing a non-existent CollectionDefinitionName constant, causing invalid references.

    • The correct approach is to use the defined constant Name in your test classes, like this:

    [Collection(MongoTestCollection.Name)]
      public class MongoDBTicketsAppServiceTests
      {
          // Test code here
      }
    
    • If your generated test classes reference MongoTestCollection.CollectionDefinitionName, you should replace it with MongoTestCollection.Name to match the actual constant defined in the MongoTestCollection class.

    • This is a known pattern in ABP's MongoDB test template. You can refer to the official template for correct usage:

      • https://github.com/abpframework/abp/tree/dev/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests
    • For more details on MongoDB test setup in ABP microservice projects, see:

      • https://abp.io/docs/latest/guides/microservice-mongodb
      • https://github.com/abpframework/abp/pull/3982
    • To summarize, update your test classes to use MongoTestCollection.Name instead of CollectionDefinitionName to resolve the invalid reference.

    Sources:

    • https://abp.io/docs/latest/guides/microservice-mongodb
    • https://github.com/abpframework/abp/tree/dev/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests
    • https://github.com/abpframework/abp/pull/3982

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    mike3077 created

    Yes we know. We are reporting that the ABP Studio Suite is generating the incorrect ref.

  • User Avatar
    0
    mike3077 created

    We are reporting this as a bug. Please reset our alloted question count. Thanks!

  • User Avatar
    0
    mike3077 created

    Also the github links do not reflect what ABP Suite is generating.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @mike3077,

    Thanks for your reporting. I created an issue for it and refunded your question credit.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on October 13, 2025, 08:48