Page 1 of 1

DataContext ctor / iqml question

Posted: Thu 21 Jul 2011 20:19
by PatrickG
Hello,

I'm looking for more information on iqml files. Currently when I try to create a new instance of a Devart.Data.Linq.DataContext object (ctor=DataContext(string connectionString, MappingSource mapping)), I get an exception. Unfortunately that exception doesn't contain any useful (to me) information about the problem. I'm guessing the problem is with my MappingSource, but I don't know what specifically is wrong with it.

The Exception that I get is:

System.ArgumentException was unhandled by user code
Message=An item with the same key has already been added.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Devart.Data.Linq.Mapping.MetaTypeBase.Initialize()
at Devart.Data.Linq.Mapping.aw.b()
at Devart.Data.Linq.Mapping.u.b()
at Devart.Data.Linq.Mapping.ay..ctor(MetaModel A_0, MetaTable A_1, ae A_2, Type A_3, MetaType A_4)
at Devart.Data.Linq.Mapping.u..ctor(av A_0, ak A_1, ae A_2, Type A_3)
at Devart.Data.Linq.Mapping.ak..ctor(av A_0, d A_1, Type A_2)
at Devart.Data.Linq.Mapping.av.b()
at Devart.Data.Linq.Mapping.av.e()
at Devart.Data.Linq.Mapping.av..ctor(MappingSource A_0, Type A_1, t A_2)
at Devart.Data.Linq.Mapping.XmlMappingSource.CreateModel(Type dataContextType)
at System.Data.Linq.Mapping.MappingSource.GetModel(Type dataContextType)
at Devart.Data.Linq.DataContext.a(Object A_0, MappingSource A_1, Type A_2)
at Devart.Data.Linq.DataContext..ctor(String connectionString, MappingSource mapping)

Is there any documentation on the requirements of an iqml file? In my case I am trying to convert an existing xml file generated by sqlmetal from a SQL Server database, so I think I must just be missing some value(s) that you require but LinqToSql and Sql Server do not.

Thank you,

Patrick

Posted: Fri 22 Jul 2011 11:54
by StanislavK
This issue may occur, e.g., if a table description in the mapping file has two Column nodes with the same 'Name' property.

Generally, the proper way of preparing the XML mapping file is to set the "Mapping Mode" model property to 'File'. In this case, Entity Developer will create a '[YourDataContext].xml' file which can be used to create the MappingSource object. Please try this approach and tell us if this helps.

Using the XML file generated for a SQL Server database may lead to errors, at least because this file describes column data types, which are different for PostgreSQL and SQL Server.

Posted: Fri 22 Jul 2011 22:17
by PatrickG
It turns out that was the problem, so thank you for you help with that. Still it would be nice if there were some documentation on the properties and attributes, there possible values and what it all means.

Patrick

Posted: Mon 25 Jul 2011 10:20
by StanislavK
Glad to see that the problem was resolved.

Thank you for your suggestion, we will consider describing the file mapping in more details. We are working on our documentation, and would be grateful if you specify other aspects of LinqConnect that should have a better description.