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

Renaming the Table Name causes error as it has foreign key defined #628

Closed
archanasoni opened this issue Sep 18, 2018 · 3 comments
Closed

Comments

@archanasoni
Copy link

Hi,

We are planning to support Code First in IBM Entity Framework Provider. We have one use cases which we found during our internal testing and need guidance on how to handle it.
Problem is when we rename table which is having foreign key defined in it, as part of add-migration operation only renameTable(...) gets generated.
when we run update-database we get error that table can not be renamed.

So if we remove foreign key dependency it works perfectly fine.

So if we handle this we need to perform below steps:

  1. Figure out whether table has PK or FK
  2. if it has then gether all the required data like constraint name, parent table, parent table_column name etc. incase of composite key we need to have list of columns.
  3. then drop the keys
  4. rename table
  5. then add key back using data collected in step 2.

It's going to be more effort just to rename table
Our question is:

  1. What is the easiest way to achieve it.
  2. Why doesn't MS EF generate drop and create key operation along with rename operation ? in this way it would have been more easy for providers to handle..
@archanasoni
Copy link
Author

Do we have any update on this ?
In EF core we could observe dropping and creating back PK and FK are taken care but for index rename operation is being generated inplace of drop and create back. Due to which even there we are hitting the same issue.

@ajcvickers
Copy link
Member

@archanasoni If your provider doesn't support this operation, then unfortunately that's just the way it is. We're not going to be making any significant changes to EF6 migrations at this time.

@ajcvickers
Copy link
Member

EF Team Triage: This issue is not something that our team is planning to address in the EF6.x code base. This does not mean that we would not consider a community contribution to address this issue.

Moving forwards, our team will be fixing bugs, implementing small improvements, and accepting community contributions to the EF6.x code base. Larger feature work and innovation will happen in the EF Core code base (https://github.com/aspnet/EntityFramework).

Closing an issue in the EF6.x project does not exclude us addressing it in EF Core. In fact, a number of popular feature requests for EF have already been implemented in EF Core (alternate keys, batching in SaveChanges, etc.).

BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

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

2 participants