212
Vote

Unique Constraints (Unique Indexes)

description

Support unique constraints on non-key columns

comments

Deus42 wrote Aug 8, 2012 at 2:15 PM

Guyz, srsly?

realstrategos wrote Sep 19, 2012 at 2:28 PM

agreed ...

jez9999 wrote Nov 5, 2012 at 10:01 AM

This issue basically seems to be a subset of issue #57 - Allow indexes to be specified using attribute/fluent API. A unique constraint just uses a unique index to enforce the constraint anyway, so I suggest people voting for this issue vote for issue #57.

AndriySvyryd wrote Nov 7, 2012 at 9:19 PM

@jez9999:
While SQL Server may use a unique index to enforce a unique constraint it's not the whole story.

This work item is about creating unique constraints so that they could be used in FK relationships.

Work item #57 is just about creating indexes.

So, even though they are related, neither is a subset of the other.

SimonLampen wrote May 6, 2013 at 2:30 AM

This work item is about creating unique constraints so that they could be used in FK relationships.
Agreed,
all I want to be able to do is have some flexibility around FK relationships so we don't have to reduce our database schema to single column primary key relationships everywhere. Composite column unique keys are common. Please help us by supporting them or at least point out why they are so hard to support.
This issue is the 3rd most requested on uservoice but it keeps getting bumped.

divega wrote Aug 14, 2013 at 10:13 AM

Note for triage: we discussed recently about trying to at least start this work in the next version.

microchip78 wrote Aug 21, 2013 at 12:50 AM

would like to see the unique constraint implemented from the entitytypeconfig class on specific property ...

dlandi wrote Sep 15, 2013 at 12:13 AM

Hello Entity Framework Team,

Would love to see work started on this...

I was really surprised when an Association was not generated for ALL of my Foreign Keys in the Entity Model.

Seems like a major hole...

-dennis

kxag wrote Nov 15, 2013 at 12:58 PM

I m trying to model a database in which i had to change primary keys in order to use TPH inheritance and then the foreign key relations were broken. Entity framework is not very flexible yet. Nor 1 -1 realtions work this way ... sad...

tidyui wrote Dec 6, 2013 at 11:44 AM

Any idéa of if/when this will be implemented? I'm (and probably many more) stuck with inserting plain SQL into my database seed to create these indexes.

TonyBao wrote Jan 14 at 3:30 PM

Any updates on this issue?

mattcsharp wrote Jan 27 at 9:36 PM

An additional side effect of this issue is that 1:0..1 associations aren't modeled correctly in a SQL database, as referenced here: https://entityframework.codeplex.com/workitem/1468

Thank you

csharperhd wrote Mar 11 at 11:29 PM

why is this still not in EF.

bartelia wrote Mar 17 at 6:35 PM

Agreed on the importance of this issue.

Use case:
'root' table - contains a two column, composite primary key.
An 'associated' table links to the root table via an ID that is not the two composite Pk. The ID is unique and carries an appropriate index (It could even be a RowGuid of the root table).

Now you wish to flatten two tables together but cannot as the associated table is related to the root table NOT via the pk.

ehasson wrote Mar 18 at 12:56 AM

This is an important feature.

weitzhandler wrote Apr 2 at 3:12 AM

Very compelling!!!

jakesteele wrote Jun 19 at 4:57 PM

Ran into a case where my data is coming in from salesforce using different String ids then my internal auto generated ids, this would have been very helpful if it was implemented.

jonjw19 wrote Jun 30 at 7:10 PM

This issue is really complicating new adoption of EF at my company, how is there still no ETA for such a huge problem?

jimmyzimms wrote Jul 1 at 4:58 PM

Agreed with jonjw19. This is just ORM fundamentals here folks. I understand that not everything can be done at once and that huge amounts of legacy cruft exists in this codebase due to the legacy of older EF versions that in retrospect were bad design or incompletely thought out design choices but the lack of a clear roadmap is just criminal.