Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Issue: Entity Diagram does not detect Associations when Indexes Created before foreign keys [667]

$
0
0
The Entity diagram tool that uses "update model from database..." will fail to include associations (detected via foreign keys) if, when the database was created, the indexes were put on the foreign key columns before the foreign keys themselves were defined.<br /><br />I think the massive query it uses to find the foreign keys (captured via a trace) makes certain bad assumptions about unique_constraint_name and constraint_name join's deep in an inner join to exclude anything where the index was created (and marked as the unique_constraint_name in the information_schema table) before the foreign key was put into place.<br /><br />See attached examples: The attached file contains a broken (first 1/2) creates tables, then indexes, then keys. The 2nd half (working) creates tables, then keys, then indexes. The net effect to sql server is *exactly* the same, but the EF generator does not notice the foreign keys and so the associations are not setup.
Comments: The fix for this should be as simple as adjusting the huge information_schema query that determines such things. If the query weren't so gigantic in first place I'd see about adjusting it myself, but I don't know which part to adjust to get the result. None the less, I would guess it as simple as removing some assumptions about what table or where clauses to use in the information_schema query. Ge to it when you can, though. I appreciate it being acknowledged :)

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>