The selected database contains foreign keys that create a cycle

You may get the following error when creating data scripts with MSSQL 2008: The selected database contains foreign keys that create a cycle. Publishing data only is not supported for databases with cyclical foreign key relationships. This problem is caused by self-referencing tables and it is given even if you don’t export data from one of such tables. Here is simple and very dirty solution.

If some of tables in the list of exported tables has circular references or some of these tables refers to table with circular references then this error occurs. As a very dirty workaround you can temporarily remove circular foreign keys and create them later again. Not very nice solution but works for me.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    One thought on “The selected database contains foreign keys that create a cycle

    Leave a Reply

    Your email address will not be published. Required fields are marked *