-
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
EF7 One to one relation results tables associated with simple one to many relationship #4792
Comments
Are you using RC1? If so, the work to introduce indexes on FK properties wasn't yet done. We've since implemented this so that you'll get a unique index on the FK property of a one-to-one (#3764). This will ship in RC2. |
yes im using the "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final" |
the problem still exist in rc2 even with fluent api its not possible to create one to one relation |
Reopening. From talking to @ajcvickers and @smitpatel it seems we don't affect the uniqueness of the FK side when setting up a 1:1 relationship. |
@divega I don't think we talked about this. The code above explicitly creates a one to one relationship using the fluent API. The original bug was the Migrations ignores our metadata about this and instead relies on the idea that we will by convention also create a unique index for the FK column. Therefore if you use Migrations to create the database you will get a unique index on the FK column, unless you remove that unique index, in which case you won't. Regardless, the relationship is always one to one in our metadata and treated as such. What we discussed on Friday was that if the relationship would be one to many in our metadata because it has only one reference nav property, then we won't check to see if the app put an explicit unique index on the FK property and use this to change the relationship to one to one. |
@1amirjalai can you open a new issue with details of the issue you are seeing (be sure to include code to reproduce the issue etc.). |
@rowanmiller the issue is created here #5623 |
Closing this as all the relevant details are in #5623. |
Even when I try the sample code in Microsoft ef7 one to one docs the result is blog and blogimage as one to many
Sample from Ms site https://docs.efproject.net/en/latest/modeling/relationships.html#one-to-one
class MyContext : DbContext
{
public DbSet Blogs { get; set; }
public DbSet BlogImages { get; set; }
The text was updated successfully, but these errors were encountered: