a compilation error

2 posts, 0 answers
  1. Vitaliy
    Vitaliy avatar
    36 posts
    Member since:
    Dec 2008

    Posted 11 Mar Link to this post

    I've got an exception when tried to compile my project:

    Object reference not set to an instance of an object.
    ExceptionString:
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Telerik.OpenAccess.Metadata.Fluent.SimpleForeignKeyAssociationFactory.CreateForeignKeyColumn(MetaPersistentType sourceType)
       at Telerik.OpenAccess.Metadata.Fluent.SimpleForeignKeyAssociationFactory.CreateMetaAssociationObject()
       at Telerik.OpenAccess.Metadata.Fluent.AssociationItemFactory.CreateMetaAssociation()
       at Telerik.OpenAccess.Metadata.Fluent.NavigationPropertyConfiguration.CreateAssociation(AssociationItemFactory associationItemFactory, MetaType persistentType)
       at Telerik.OpenAccess.Metadata.Fluent.NavigationPropertyConfiguration.CreateConceptualItem(FluentMetadataSource fluentMappingSource, MetaType persistentType)
       at Telerik.OpenAccess.Metadata.Fluent.PropertyConfiguration.AddConceptualItem(FluentMetadataSource fluentMappingSource, MetaType persistentType)
       at Telerik.OpenAccess.Metadata.Fluent.MappingConfiguration.AddMasterAssociationMapping(FluentMetadataSource fluentMappingSource, MetadataContainer metadataContainer)
       at Telerik.OpenAccess.Metadata.Fluent.FluentMetadataSource.ProcessAssociations(MetadataContainer metadataContainer)
       at Telerik.OpenAccess.Metadata.Fluent.FluentMetadataSource.CreateModel()
       at DataDomain.FluentMapping.PMSMetadataSource.CreateModel() in C:\dev\PMS_VS2015_NewTelerikDataAccess\DataDomain\FluentMapping\PMSMetadataSource.cs:line 23
       at Telerik.OpenAccess.Metadata.Fluent.FluentMetadataSource.GetModelCore(MetadataContainer old)
       at Telerik.OpenAccess.Sdk.Enhancer.Enhancer.CrossDomainRunImpl(AssemblyLoader assemblyLoader)
       at Telerik.OpenAccess.Sdk.Enhancer.EnhancerBase.CrossDomainRun()DataDomainC:\dev\PMS_VS2015_NewTelerikDataAccess\DataDomain\obj\Debug\DataDomain.dll

     

    using System;
    using Telerik.OpenAccess.Metadata;
    using Telerik.OpenAccess.Metadata.Fluent;
     
    namespace DataDomain.Property
    {
        public class LettingLeasing
        {
            public static MappingConfiguration GetMapping()
            {
                var cfg = new MappingConfiguration<LettingLeasing>();
                cfg.MapType().UseDefaultMap().ToTable("LEASEASSIGNMENT");
                cfg.HasProperty(c => c.ID).IsIdentity(KeyGenerator.Autoinc);
                cfg.HasAssociation(c => c.NewAlternativeBillingAddress).ToColumn("NewTenantABA"); // <==== THIS ROW CAUSED THIS
                return cfg;
            }
     
            public int ID { get; private set; }
            public DateTime? DisplayUntil { get; set; }
            public PMSAlternativeBillingAddress NewAlternativeBillingAddress { get; set; }
        }
    }

     

  2. Vitaliy
    Vitaliy avatar
    36 posts
    Member since:
    Dec 2008

    Posted 11 Mar in reply to Vitaliy Link to this post

    Oh, yeah, I made a mistake.

    Mapped two classes to the same table - 'LEASEASSIGNMENT' and associated their two properties to the same column name 'NewTenantABA'.

    An user friendly exception would be better though.

     

  3. DevCraft banner
Back to Top