-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add GetDbSets and fix error details of incorrect Entity type full name #23946
Conversation
Bumps Microsoft.AspNetCore.OData from 7.5.2 to 7.5.4. Signed-off-by: dependabot[bot] <support@github.com>
Bumps [Microsoft.Azure.Cosmos](https://github.com/Azure/azure-cosmos-dotnet-v3) from 3.15.1 to 3.16.0. - [Release notes](https://github.com/Azure/azure-cosmos-dotnet-v3/releases) - [Changelog](https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md) - [Commits](Azure/azure-cosmos-dotnet-v3@3.15.1...3.16.0) Signed-off-by: dependabot[bot] <support@github.com>
…with name and type of entity
"Cannot create a DbSet for '{typeName}' because this type is not included in the model for the context" for Developers to find duplicate types with different namespaces When you have duplicate entity with same name you will get this error with namespaces and your entity types you can find the problem easier
…ft.Azure.Cosmos-3.16.0 Bump Microsoft.Azure.Cosmos from 3.15.1 to 3.16.0
…ft.AspNetCore.OData-7.5.4 Bump Microsoft.AspNetCore.OData from 7.5.2 to 7.5.4
…t/Microsoft.Azure.Cosmos-3.16.0 Revert "Bump Microsoft.Azure.Cosmos from 3.15.1 to 3.16.0"
…t/Microsoft.AspNetCore.OData-7.5.4 Revert "Bump Microsoft.AspNetCore.OData from 7.5.2 to 7.5.4"
….ToArray() for test cases to check true full text of error
… GetDbSets method
@Ali-YousefiTelori How does knowing the types that are in the model help people resolve this error? |
@ajcvickers In the past week, We got a problem with our project that got a developer one day time to find the problem and fix it. We had two entities with the same name but different namespace: 1.TransactionInfo in SQL Relational example: SqlNamesapce.TransactionInfo With a developer mistake who use SqlNamesapce.TransactionInfo in DBSets of SqlDbContext but he sent MogoNamespace.TransactionInfo to context.Set... to get DbSet and add data to the database. DbSet<TInfo> table = context.Set<TInfo>();
await table.AddAsync(info);
await context.SaveChangeAsync(); I think these codes I pushed, will help the developer to know the Namespace of entities when they are setting the wrong type of context.Set and they will find the bug faster. |
…ic types better and use GroupBy ShortName to to remove dupplicate type names
src/EFCore/DbContext.cs
Outdated
/// <returns> | ||
/// the name with different namespace found | ||
/// </returns> | ||
internal string FindSameTypeNameWithDifferentNamespace(Type type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to Microsoft.EntityFrameworkCore.Metadata.Internal.EntityTypeExtensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and moved
Co-authored-by: Andriy Svyryd <AndriySvyryd@users.noreply.github.com>
…orkCore.Metadata.Internal.EntityTypeExtensions
Thanks for your contribution. |
Your types:
EFCoreCheckSpace.User,
MyNewNameSpace.TransactionInfo"