-
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
Migrations: ModelDiffer should find diff on navigations #5155
Comments
Thinking about how this information can be used, I've can only think of one case:
Are there any others? @ajcvickers @AndriySvyryd @anpete @divega |
@bricelam that is the same one I was aware of. |
FWIW, you mentioned it when you created the original bug #2140. |
Oh good, my brain is deterministic over a duration of at least one year. |
Here is the rule I've come up with. If a would-be-added property is part of one or more foreign key constraints, and any of those foreign key constraints...
...then treat it as a renamed column. Irrelevant information:
Sound good? |
Here are some simple cases it covers. class Person {
public int Id { get; set; }
public ICollection<Book> Books { get; }
}
class Book {
- public int PersonId { get; set; }
+ public int AuthorId { get; set; }
public Person Author { get; set; }
} class Person {
public int Id { get; set; }
- public ICollection<Book> Books { get; }
+ public ICollection<Book> AuthoredBooks { get; }
}
class Book {
- public int PersonId { get; set; }
+ public int AuthorId { get; set; }
public Person Author { get; set; }
} class Person {
public int Id { get; set; }
public ICollection<Book> Books { get; }
}
class Book {
- public int PersonId { get; set; }
- public Person Person { get; set; }
+ public int AuthorId { get; set; }
+ public Person Author { get; set; }
} It may lead to unexpected renames and alters if you change the type to a property that doesn't convert. class Person {
- public int Id { get; set; }
+ public Guid Guid { get; set; }
public ICollection<Book> Books { get; }
}
class Book {
- public int AuthorId { get; set; }
+ public Guid AuthorGuid { get; set; }
public Person Author { get; set; }
} Before this change, you'd get |
Sounds good to me. |
@bricelam if you try to remove an existing FK and add a new FK that points to a different alternate key in the same entity type as the principal side, what would happen? (I think it is a bit ambiguous in the rules you described, but I hope it isn't in the implementation 😄). |
Closing in favor of doing #6582 instead. |
ModelSnapshot contains navigation information now. ModelDiffer should utilize this info in computing differences.
The text was updated successfully, but these errors were encountered: