Fluent Multiple Models - error

2 posts, 0 answers
  1. bberdel
    bberdel avatar
    20 posts
    Member since:
    Jun 2006

    Posted 17 May Link to this post

    We are in the process of migrating our previous models (rlnq) to the the fluent code only model.  Followed the instructions to do so and generate all code, etc. 

    After reading the documentation, there doesn't seem to be anything we need to do for multiple models / context and metadata to exist.  They are currently in two seperate folders, but the same namespace

    We have two seperate models, when building we are receiving the following error:  

     

    Error   Found explicit primitive change to 'Name' which says that the old value 'DataDbContext' should be changed with 'RepositoryDbContext'. One can only add elements and not modify primitive properties of MetaItems.This has occurred on the MetaItem with name 'RepositoryDbContext' and type 'Telerik.OpenAccess.Metadata.MetadataContainer'
    ExceptionString:
    Telerik.OpenAccess.Exceptions.InvalidOperationException: Found explicit primitive change to 'Name' which says that the old value 'DataDbContext' should be changed with 'RepositoryDbContext'. One can only add elements and not modify primitive properties of MetaItems.This has occurred on the MetaItem with name 'RepositoryDbContext' and type 'Telerik.OpenAccess.Metadata.MetadataContainer'
       at Telerik.OpenAccess.Metadata.AggregateChangeSetEntryVisitor.ThrowExplicitChangeFoundException(ChangeSetDetail detail, MetaItem item)
       at Telerik.OpenAccess.Metadata.AggregateChangeSetEntryVisitor.CheckForNonDefaultOperation(ChangeSetDetail detail, MetaItem item)
       at Telerik.OpenAccess.Metadata.AggregateChangeSetEntryVisitor.Visit(ChangeSetEntry changeSetEntry)
       at Telerik.OpenAccess.Metadata.ChangeSetWorker.TraverseChangeSetEntry(ChangeSetEntry changeSetEntry, IChangeSetEntryVisitor visitor)
       at Telerik.OpenAccess.Metadata.AggregateMetadataSource.ApplyExtender(MetadataContainer firstContainer, MetadataContainer secondContainer)
       at Telerik.OpenAccess.Metadata.AggregateMetadataSource.CreateModel()
       at Telerik.OpenAccess.Metadata.MetadataSource.GetModelCore(MetadataContainer old)
       at Telerik.OpenAccess.Sdk.Enhancer.Enhancer.CrossDomainRunImpl(AssemblyLoader assemblyLoader)
       at Telerik.OpenAccess.Sdk.Enhancer.EnhancerBase.CrossDomainRun()McMDataAccessE:\McM\McMDataAccess\obj\Debug\McMDataAccess.dll

  2. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 19 May Link to this post

    Hi bberdel,

    This error is expected in the scenario when a project contains more than one model and they are converted to the fluent mapping type. Fortunately, this is only a matter of code generation and can be easily fixed. Following are the details.

    By default, when the Enhancer tool processes a project that contains multiple metadatasource classes, it checks if the container names are the same and if the models are in one and the same namespace. In your situation, when you changed the mapping type of the models, the designer generated different container names for all of them (you can check the SetContainerSettings methods in the metadatasource classes) and Enhancer threw an error to notify you about this. The resolution is to remove the following two code lines in all of the metadatasource classes:
    container.Name = "MyFluentModel";
    container.DefaultNamespace = "MyNamespace";

    As a note: Enhancer treats differently the .rlinq files and the fluent models. This is why you do not see such errors with multiple .rlinq files in the project.

    Additionally, it is a good idea to check the connection strings. Given the fact that you have two different models, if they consume different databases, you need to have two semantically different connection strings. This section in our documentation will provide you with further information about the consumption of multiple models. 

    I hope this helps.

    Regards,
    Doroteya
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
Back to Top