Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # IT:AD:EF/CodeFirst:HowTo:Migrations # <callout type="Navigation" class="small"> * [[../|(UP)]] {{indexmenu>.#2|nsort tsort}} * IT:EF/CodeFirst:HowTo:Migrations * See also: * [[IT/AD/SQL Server/HowTo/Run a Transaction Without Committing]] </callout> <panel title="Summary"> If you have a table that has a Guid PrimaryKey, and you create a table that references it via an FK (therefore gets a Guid FK property)... and then you decide to change it to an int based relationship.. </panel> ## Process ## You're truly FUBAR. <WRAP important> EDIT: The basis of the problem is that the Id is the Clustered Index -- the order in which the rows are actually ordered in the table. And SQL Server doesn't allow you to change a tables clustered index, without dropping/recreating the table. * http://blog.sqlauthority.com/2009/05/03/sql-server-add-or-remove-identity-property-on-column/ </WRAP> I never got the whole way through, but so far: * Drop the FK between the two. * Drop the index of the Primary table. * Drop the Default value (that generated the NEWSEQUENTIALID()) -- that part i could not work out. * Change the Principal Id type. * Change the Dependent Id type. * Create the index to the primary table. * Create the relationship between the two. The solution I did was: punch the screen. * Add mappings to Ignore the Entities * Dropped any FK properties on Dependents tables. * Generated the Migration. * Readded the table. * Grrr. /home/skysigal/public_html/data/pages/it/ad/code_first/howto/migrations.txt Last modified: 2023/11/04 03:39by 127.0.0.1