create xml schema collection

wnd 1 Reputation point
2021-06-28T11:21:28.563+00:00

Hi, got metadata xml file https://pastebin.com/sbT4X6uC
My need is to parse it into SQL DDL script(s) w/ FK.

I'm trying to use it with

CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS  
N' <?xml ... >';

But getting

Error invoking remote method 'DB_EXECUTE_CANCELLABLE_QUERY': RequestError: Expected XML schema document

Is there anything I can do to fix it so that I can use "create xml schema collection"? Or is there any other known way to extract SQL DDL w/ FK? Or at least just SQL DDL w/o FK?

Please advise.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,585 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Olaf Helper 40,576 Reputation points
    2021-06-28T11:36:38.377+00:00

    Expected XML schema document

    By the error message I guess you didn't use a valid XSD to create the collection. How does your XSD look like; you posted only a very small part of it?


  2. AmeliaGu-MSFT 13,961 Reputation points Microsoft Vendor
    2021-06-29T03:11:12.267+00:00

    Hi wnd-4239,

    Welcome to Microsoft Q&A.
    The database has constraints and schema elements which can enforce the logical correctness of the data. Unlike the database, there is nothing built into a text editor to prevent errors when creating an XML Document. For the XML, this has to be defined separately in an XSD document. The XSD itself is in an XML language and is therefore also both human readable and somewhat self descriptive. Please refer to this doc and this article which might help.

    Or is there any other known way to extract SQL DDL w/ FK?

    We can use the Generate Scripts wizard create scripts for DDL with FK. Please right-click database ->Tasks-> select Generate Scripts.

    109950-image.png

    Then we can select specific objects in Choose Objects page to choose which objects you want to include in the scripts.

    110094-image.png

    Please refer to this tutorial which might help.

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Yitzhak Khabinsky 24,836 Reputation points
    2021-06-29T04:03:37.473+00:00

    HI anonymous user-4239,

    EDMX is Visual Studio's "container" for the metadata about your Entity Data Model.
    An .edmx file is an XML file that defines the following:

    • a conceptual model
    • a storage model,
    • the mapping between these models.

    The EDMX visual designer has a options available from its right-click context menu: "update model from database", and also "Generate database from model".
    It is done based on a storage model.

    MS official documentation: Entity Data Model for Data Services Packaging Format

    0 comments No comments