📜 ⬆️ ⬇️

Database Script Generation by Entity Framework Data Model

The future version of the Entity Framework model editor in Visual Studio expects such useful functionality as reverse database generation by data model (SSDL - Storage Schema Definition Language). But as long as it does not exist, you can use XSLT transformation, which will help you get code from the XML description of the SQL-DDL storage model to create tables and links in the database.

This is the transformation that I want to share . Probably, for some cases, he may need further work, but for my task (to recover a lost database in the presence of an EDMX file), it came up perfectly. Actually, for this purpose I wrote it :)

To prepare the conversion, create an .xml file in Visual Studio into which you can paste the contents of the SSDL block (the Schema tag, and without attributes).
')
An example of the source XML file .

Then, after opening the file with the conversion in Visual Studio, select Xml -> Show XSLT Output. In the dialog that appears, select the created XML file and, voila, a new window will open with the SQL code for creating the tables and connections of your database.

My work blog

Source: https://habr.com/ru/post/50626/


All Articles