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

dotnet-ef scaffolding issue starting .NET 6 #26631

Closed
freshe opened this issue Nov 11, 2021 · 1 comment
Closed

dotnet-ef scaffolding issue starting .NET 6 #26631

freshe opened this issue Nov 11, 2021 · 1 comment

Comments

@freshe
Copy link

freshe commented Nov 11, 2021

Starting .NET 6 (dotnet-ef 6.0.0) I can no longer reverse engineer our company database.
Seems to be because of ambiguity of foreign key column names. No problem in dotnet-ef 5.x.

The property or navigation 'Groups' cannot be added to the entity type 'SomeTable (Dictionary<string, object>)' because a property or navigation with the same name already exists on entity type 'SomeTable (Dictionary<string, object>)'.

Reproduced it with a small test database.

dotnet ef dbcontext scaffold "Server=localhost;Database=EfTest;User Id=sa;Password=password" Microsoft.EntityFrameworkCore.SqlServer --context DbContext --output-dir "Data"

--


CREATE DATABASE EfTest
GO

USE EfTest
GO

CREATE TABLE GroupTable1
(
	GroupId INT NOT NULL,
	Name NVARCHAR(100) NOT NULL

	PRIMARY KEY (GroupId)
)

CREATE TABLE GroupTable2
(
	GroupId INT NOT NULL,
	Name NVARCHAR(100) NOT NULL

	PRIMARY KEY (GroupId)
)

CREATE TABLE SomeTable
(
	SomeId INT NOT NULL,
	Name NVARCHAR(100) NOT NULL,

	PRIMARY KEY (SomeId)
)

CREATE TABLE SomeJoinTable1
(
	SomeId INT NOT NULL,
	GroupId INT NOT NULL,

	PRIMARY KEY (SomeId, GroupId),
	FOREIGN KEY (SomeId) REFERENCES SomeTable (SomeId),
	FOREIGN KEY (GroupId) REFERENCES GroupTable1 (GroupId)
)

CREATE TABLE SomeJoinTable2
(
	SomeId INT NOT NULL,
	GroupId INT NOT NULL,

	PRIMARY KEY (SomeId, GroupId),
	FOREIGN KEY (SomeId) REFERENCES SomeTable (SomeId),
	FOREIGN KEY (GroupId) REFERENCES GroupTable2 (GroupId)
)
@smitpatel
Copy link
Member

Duplicate of #26496

@smitpatel smitpatel marked this as a duplicate of #26496 Nov 11, 2021
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants