Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to ASP.NET Core 6.0 #720

Merged
merged 10 commits into from
Jul 6, 2022
Merged

Migrate to ASP.NET Core 6.0 #720

merged 10 commits into from
Jul 6, 2022

Conversation

i-rakityanskiy
Copy link
Contributor

@i-rakityanskiy i-rakityanskiy commented Jul 1, 2022

Steps to test:

  1. Verify that application components work properly:
  • Identity server
  • Elasticsearch
  • Google cloud storage
  • Quartz
  • Microsoft.CodeAnalysis.NetAnalyzers (replaced Microsoft.CodeAnalysis.FxCopAnalyzers)
  • GRPC
  • H3Lib
  • Redis
  • EmailSender

@i-rakityanskiy i-rakityanskiy requested a review from a team July 1, 2022 08:53
@i-rakityanskiy i-rakityanskiy self-assigned this Jul 1, 2022
@i-rakityanskiy i-rakityanskiy force-pushed the iraki/migrate-to-asp-net-core-6 branch 5 times, most recently from 537da18 to fdc08fd Compare July 2, 2022 08:10
@i-rakityanskiy i-rakityanskiy force-pushed the iraki/migrate-to-asp-net-core-6 branch from e1fe670 to 04acfaa Compare July 4, 2022 10:45
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 6, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@@ -11,7 +11,7 @@ namespace OutOfSchool.Tests.Common.TestDataGenerators
public static class AddressGenerator
{
private static readonly Faker<Address> faker = new Faker<Address>()
.RuleFor(x => x.Id, f => f.IndexFaker)
.RuleFor(x => x.Id, f => f.IndexFaker++)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the IndexFaker is used to generate Address.Id it causes an exception System.InvalidOperationException : The instance of entity type 'Address' cannot be tracked because another instance with the key value '{Id: 1}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.
I saw a workaround to avoid this exception here


Using f.IndexFaker++ solves this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not really good idea to change the generator trying to fix the problem with data.
Seems it was used in a wrong way.
It is better to find the reason why collection already contains the address with id 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens because IndexFaker has an initial value of 0. When entity with Id=0 is added to the DB context, EF implicitly changes Id value to 1. When the second entity with Id=1 is generated and added to the DB context it causes the exception. I think that for the testing purposes that fix is sufficient enough. At the same time I agree that better solution can be found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h4wk13 Please check this PR #733

@DmyMi DmyMi marked this pull request as ready for review July 6, 2022 08:41
@DmyMi DmyMi merged commit 52a5068 into develop Jul 6, 2022
@DmyMi DmyMi deleted the iraki/migrate-to-asp-net-core-6 branch July 6, 2022 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants