4

Is it possible to automatically convert a lot of C# classes to SQL Server database tables ?

I need to import some xml files into SQL Server but using SSIS the runtime stops working as soon as I select the xsd file. However I easily converted the xsd to class files so that's why I am asking if its possible to have a workaround...

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

3 Answers3

5

You can use Entity Framework Code First functionality, with a little extra work to get the tables done in your database.

There you have a good post on it by ScottGu

JotaBe
  • 38,030
  • 8
  • 98
  • 117
3

Yes, it's possible to automatically do this. Entity Framework has a model called Code First, which essentially does this: takes your C# classes and creates the database and tables automatically for you.

Take a look at this post by Scott Guthrie.

Icarus
  • 63,293
  • 14
  • 100
  • 115
0

Other option you might test is DataSet.ReadXml() function. Drawback is the Dataset can't handle complexType="mixed", but it deals well with large files (my files had about 50M each). All tables and columns are named by XML tags and relations are autogenerated by DataSet itself.

Peposh
  • 172
  • 7