You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Table ARTOMADU contains composite primary key from two columns, (TOODE, ARTOMALIIK)
Those columns are foreign keys to TOODE and ARTOMALIIK tables.
TOODE table contains foreign key to ARTOMALIIK table on column TOOTEPUU
In this case .NET 6 scaffold tries to create duplicate propery name and fails with exception
System.InvalidOperationException: The property or navigation 'Toodes' cannot be added to the entity type 'Artomlii (Dictionary<string, object>)' because a property or navigation with the same name already exists on entity type 'Artomlii (Dictionary<string, object>)'.
at Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType.AddNavigation(MemberIdentity navigationMember, ForeignKey foreignKey, Boolean pointsToPrincipal)
at Microsoft.EntityFrameworkCore.Metadata.Internal.ForeignKey.Navigation(Nullable`1 propertyIdentity, ConfigurationSource configurationSource, Boolean pointsToPrincipal)
at Microsoft.EntityFrameworkCore.Metadata.Internal.ForeignKey.SetPrincipalToDependent(String name, ConfigurationSource configurationSource)
at Microsoft.EntityFrameworkCore.Metadata.Internal.ForeignKey.Microsoft.EntityFrameworkCore.Metadata.IMutableForeignKey.SetPrincipalToDependent(String name)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.AddNavigationProperties(IMutableForeignKey foreignKey)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitForeignKeys(ModelBuilder modelBuilder, IList`1 foreignKeys)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.VisitDatabaseModel(ModelBuilder modelBuilder, DatabaseModel databaseModel)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.RelationalScaffoldingModelFactory.Create(DatabaseModel databaseModel, ModelReverseEngineerOptions options)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluarlize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The property or navigation 'Toodes' cannot be added to the entity type 'Artomlii (Dictionary<string, object>)' because a property or navigation with the same name already exists on entity type 'Artomlii (Dictionary<string, object>)'.
The text was updated successfully, but these errors were encountered:
kobruleht
changed the title
Scaffolding is broken in .NET6 due to many to many relationship implementation
Scaffolding cross referenced tables throws InvalidOperationException in .NET 6
Nov 22, 2021
Table ARTOMADU contains composite primary key from two columns, (TOODE, ARTOMALIIK)
Those columns are foreign keys to TOODE and ARTOMALIIK tables.
TOODE table contains foreign key to ARTOMALIIK table on column TOOTEPUU
In this case .NET 6 scaffold tries to create duplicate propery name and fails with exception
Table structures:
The text was updated successfully, but these errors were encountered: