Skip to content

Instantly share code, notes, and snippets.

@tompazourek
Last active September 7, 2015 08:11
Show Gist options
  • Save tompazourek/6b9a7ff9e4c24701d9f8 to your computer and use it in GitHub Desktop.
Save tompazourek/6b9a7ff9e4c24701d9f8 to your computer and use it in GitHub Desktop.
-- When renaming tables or moving schemas in Entity Framework, EF doesn't rename all related things (like FKs and PKs)
-- This might help to locate those database objects:
-- selects FKs and PKs with schema 'Core.' in their name
SELECT s.name, o.name FROM sys.objects AS o
INNER JOIN sys.schemas AS s ON s.schema_id = o.schema_id
WHERE o.name LIKE '%Slug%' OR o.name LIKE '%PageMetadata%'
-- performs renaming
sp_rename '[Inventory].[FK_Inventory.BaseProduct_Core.PageMetadata_PageMetadata_Id]', 'FK_Inventory.BaseProduct_Navigation.PageMetadata_PageMetadata_Id'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment