Hello,

I got an exception on Domain.Build() (perform) with DO 4.3 latest release : this is a normal exception I had something wrong in my model (duplicated field)

[Field]
public string MyField 
{
  get { return myField; }
}

[Field]
private string myField {get;set;}

Obviously the first [Field] attribute is a mistake.

However the exception should have been more informative:

System.ArgumentException occurred
  Message=An item with the same key has already been added.
  Source=mscorlib
  StackTrace:
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at Xtensive.Sql.Model.NodeCollection`1.Add(TNode item)
       at Xtensive.Sql.Model.PairedNodeCollection`2.Add(TNode item)
       at Xtensive.Sql.Model.TableColumn.ChangeDataTable(DataTable value)
       at Xtensive.Sql.Model.DataTableNode.set_DataTable(DataTable value)
       at Xtensive.Sql.Model.DataTableNode..ctor(DataTable dataTable, String name)
       at Xtensive.Sql.Model.DataTableColumn..ctor(DataTable dataTable, String name)
       at Xtensive.Sql.Model.TableColumn..ctor(Table table, String name, SqlValueType dataType)
       at Xtensive.Sql.Model.Table.CreateColumn(String name, SqlValueType dataType)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.CreateColumn(ColumnInfo columnInfo, Table table)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitCreateColumnAction(CreateNodeAction createColumnAction)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitCreateAction(CreateNodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitAction(NodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitAction(NodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitAction(NodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitAction(NodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitAction(NodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitAction(NodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.VisitAction(NodeAction action)
       at Xtensive.Storage.Providers.Sql.SqlActionTranslator.Translate()
       at Xtensive.Storage.Providers.Sql.SchemaUpgradeHandler.UpgradeSchema(ActionSequence upgradeActions, StorageInfo sourceSchema, StorageInfo targetSchema)
       at Xtensive.Storage.Building.Builders.DomainBuilder.SynchronizeSchema(SchemaUpgradeMode schemaUpgradeMode)
       at Xtensive.Storage.Building.Builders.DomainBuilder.BuildDomain(DomainConfiguration configuration, DomainBuilderConfiguration builderConfiguration)
       at Xtensive.Storage.Upgrade.UpgradingDomainBuilder.BuildStageDomain(UpgradeStage stage)
       at Xtensive.Storage.Upgrade.UpgradingDomainBuilder.Build(DomainConfiguration configuration)
       at Xtensive.Storage.Domain.Build(DomainConfiguration configuration)

Could you add an informative message for this one (or possibly a generic message for this part of code) mentioning the offending table/column/... ?

Thanks, Julien


Updated at 21.07.2010 9:58:44

To tony:

An trick in that case is to double-click in "Stack trace" to the methods on top of stack trace and use the "Locals" window in visual studio, which allow to see the local variables where the exception is thrown.

That's how I found where the problem was.

[attachment=0:1257vwhs]debug.png[/attachment:1257vwhs]


Updated at 26.07.2010 14:00:17

Another case of vague exception message:

Xtensive.Storage.DomainBuilderException occurred
  Message=Unsupported type: 'DataSet'.
  Source=Xtensive.Storage
  StackTrace:
       at Xtensive.Storage.Building.Validator.ValidateFieldType(TypeDef declaringType, Type fieldType, Boolean isKeyField)
       at Xtensive.Storage.Building.ModelInspector.InspectField(TypeDef typeDef, FieldDef fieldDef, Boolean isKeyField)
       at Xtensive.Storage.Building.ModelInspector.Inspect(TypeDef typeDef)
       at Xtensive.Storage.Building.ModelInspector.InspectTypes()
       at Xtensive.Storage.Building.ModelInspector.Run()
       at Xtensive.Storage.Building.Builders.ModelBuilder.Run()
       at Xtensive.Storage.Building.Builders.DomainBuilder.BuildModel()
       at Xtensive.Storage.Building.Builders.DomainBuilder.BuildDomain(DomainConfiguration configuration, DomainBuilderConfiguration builderConfiguration)
       at Xtensive.Storage.Upgrade.UpgradingDomainBuilder.BuildStageDomain(UpgradeStage stage)
       at Xtensive.Storage.Upgrade.UpgradingDomainBuilder.Build(DomainConfiguration configuration)
       at Xtensive.Storage.Domain.Build(DomainConfiguration configuration)

Could you give type and property in expression message?

This would be really more practical.

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Jul 20 '10 at 10:50

olorin's gravatar image

olorin
358848792

(Jul 20 '10 at 10:50) Alex Yakunin Alex%20Yakunin's gravatar image

Tony wrote: I agree, I got the Message 'An item with the same key has already been added' last night, and spent hours looking how a duplicate key value was being added.

Apart from the misleading message it does not tell you what class the error applies too.

(Jul 20 '10 at 10:50) Editor Editor's gravatar image

One Answer:

Tony wrote:

Thanks for that, but my 'An item with the same key has already been added' was a bit more complicated.

I had changed a table hierarchy from the default to single table, and none of the model upgrade options would work, when the build failed it threw the 'An item with the same key has already been added' exception, clear as mud.

In the the end I had to backup the postgress database, do a recreate on the model, and then restore the data. The table hierarchy that was changed luckly did not have any data in it yet.


Alex (Xtensive) wrote:

True, changing inheritance schema mapping is may be the most complex upgrade case. Frankly speaking, it's hardly looks like a case we can support in nearby future (requires pretty big amount of work). The only thing we can implement fast here is proper detection & error reporting of this case.

The best way to perform such an upgrade:

  • Clone the old hierarchy, but mark all the types as [Recycled(...)] there

  • Implement manual data copying from old to new hierarchy in UpgradeHandler.

  • I strongly recommend to rely on Recreate mode during debugging \ testing, and write schema upgrade code only on releases. Recreate is perfect for unit testing on build agents as well.

answered Jul 21 '10 at 11:18

Editor's gravatar image

Editor
46153156157

To be fixed.

(Jul 21 '10 at 11:18) Alex Yakunin Alex%20Yakunin's gravatar image

olorin wrote: You're right that's more complex than mine ;)

(Jul 21 '10 at 11:18) Editor Editor's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×573
×52

Asked: Jul 20 '10 at 10:50

Seen: 3,432 times

Last updated: Jul 20 '10 at 10:50

powered by OSQA