e1s
e1s

Reputation: 375

Entity Framework Core create code-first base from xsd file

I have a xsd file and I need create MS SQL database from this file. I use code-first and try create classes for migration. I try use xsd2code++ and XmlClassSchemaGenerator, but generated classes contains arrays of primitive type and no connection between classes.

'The property 'property_name' could not be mapped, because it is of type 'List<'string>' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.'

Is there any way to create database automatically, because xsd file is large.

Upvotes: 1

Views: 1265

Answers (1)

maik krijgsman
maik krijgsman

Reputation: 23

There is no direct way to create a database table from a XSD. you can however create a more readable .cs file.

just follow these steps:

  1. load your XSD into visual studio
  2. open it my double clicking or right click and then click open
  3. Click the "XML Schema explorer" button at the top of the page.
  4. right click the last item in you XSD file then press "Generate sample XML"

from here on you can access all the fields within your XSD.

Upvotes: 0

Related Questions