Entity references changing order upon rebuild

Upon rebuilding the model, entity references are often shuffled around. This results in an arduously long diff, which makes it difficult to review the changes for things like broken protected regions.

Could we fix the order of references, perhaps alphabetically, so that they don’t change every time?

Hi @JoAlley, welcome to the forum!
I’m happy to report that Entities, Enums, and References are already ordered alphabetically. Attributes and validators are ordered by their vertical position.

If your experience is different to this, please let us know.

Cheers, and all the best.

I have this code in the C#Bot output:

		// % protected region % [Customise CvdSubmissionss here] off begin
		/// <summary>
		/// Incoming one to many reference
		/// </summary>
		/// <see cref="Ngr.Models.CvdSubmissionEntity"/>
		[EntityForeignKey("CvdSubmissionss", "Card", false, typeof(CvdSubmissionEntity))]
		public ICollection<CvdSubmissionEntity> CvdSubmissionss { get; set; }
		// % protected region % [Customise CvdSubmissionss here] end

		// % protected region % [Customise CardMembershipss here] off begin
		/// <summary>
		/// Incoming one to many reference
		/// </summary>
		/// <see cref="Ngr.Models.CardMembershipEntity"/>
		[EntityForeignKey("CardMembershipss", "Card", false, typeof(CardMembershipEntity))]
		public ICollection<CardMembershipEntity> CardMembershipss { get; set; }
		// % protected region % [Customise CardMembershipss here] end

		// % protected region % [Customise CardOrderss here] off begin
		/// <summary>
		/// Incoming one to many reference
		/// </summary>
		/// <see cref="Ngr.Models.CardOrderEntity"/>
		[EntityForeignKey("CardOrderss", "Card", false, typeof(CardOrderEntity))]
		public ICollection<CardOrderEntity> CardOrderss { get; set; }
		// % protected region % [Customise CardOrderss here] end

As far as I can tell, these come from the ngr.csharpbotentity file, in which the CVD Submissions reference is at line 39 in my model, while the Card Orders reference is at line 76. Prior to the rebuild, the CVD Submissions reference was at line 93, while the Card Orders reference was at line 68.

(The card memberships entity, seen between CVD Submissions and Card Orders above, also had the reference entity change positions in the model file, but in both cases it was still after the CVD Submissions entity. It was not in alphabetical order before, and it has remained out of order)

@leo.mylonas I have been able to confirm that code changes are directly reflective of model changes (as it should be), without the model changing no references are re-ordered.

Upon closer inspection, we have identified some edge cases which may result in the re-ordering of the model, and as such, reordering of the bot-written code.

We will expand our sorting algorithm to handle these edges cases and let you know when the changes are live.

All the best.


Hi @JoAlley.
Just wanted to let you know that we have improved the sorting algorithm to make it more deterministic. Please see the release notes for further information.

1 Like