Generate LINQ DataContext from class XML, XSD or C #

I have a massive set of classes that I need to create from an XML file, which I really dislike doing manually. I would really like to create a LINQ DataContext, so I can use VisualStudio to create an SQL database from a DataContext.

I know that I can generate XSD and C # classes from an XML file, but are there any tools for creating the corresponding SQL Database tables or LINQ DataContext from them?

+3
source share
3 answers

You can use http://xsd2code.codeplex.com/ to create C # classes from your XSD. Remember to enable Serialization and GenerateXMLAttributes. Set the ColllectionObject type to a type that implements ICollection, such as List, do not use IList.

Then execute your DbContext as usual.

+1
source

I do not believe that LINQ to SQL supports creating a database from any model. Entity Framework in .NET 4.0 does.

Also, keep in mind that not all XML schemas correspond to valid relational database structures.

0
source

Open the XSD file in VS, create a DataSet in VS, then copy the XSD file to the data set as in design mode. This will create a typed DataContext.

-1
source

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


All Articles