Generate a database from XSD?

B

Brad Navarro

Hello,

Does anyone know if it is possible with .NET to load an XSD file and
use that as a database schema template to generate a new database? I
had hoped I could load the XSD file into a System.Data.Dataset object,
and then pass that to something like a
System.Data.SqlClient.SqlDataAdapter object and then invoke a method
that would create a database (or schema within an existing database),
but I don't see any method to do this.

I'm looking to do this because, although we are currently developing on
SQL Server 2000, we are looking to start supporting Oracle, and
possibly other databases as well. Right now, I generate about 1/2 of
the database using stored procedures that have calls like exec("create
table " + @TableName + "...") along with proprietary XML configuration
files to determine how to call these SPs. It's a bit clunky, and won't
port so easily to other databases, so I'm looking to streamline
database agnostic schema generation with something a little more
standard and robust, and my hope was that XSD and .NET would have some
kind of solution for me.

Has anybody done anything similar to this?
 
C

Cor Ligthert [MVP]

Brad,

I know that it is not possible, it seems to have been in all versions on the
role to implement it, but never was.

Hopefully it will be implemented in the next version, because this is so
often asked in these newsgroups.

Cor
 
M

Miha Markic [MVP C#]

Hi Brad,

No, not possible out of the box.
However, I don't see a big problem doing it manually - perhaps an XSLT per
database could do the trick.
Or by code if you wish - both ways don't look too complicated to me.
Perhaps you might want to take a look at ORMs - they shield you from
database and take care for you of database management (ok, it depends on
ORM).

Why do you need dynamic database generation is of course another question...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top