This is a migrated thread and some comments may be shown as answers.

Mapping for class BLGBlogPost' is specified in file 'config' but the class could not be found

10 Answers 192 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alec
Top achievements
Rank 1
Alec asked on 20 Sep 2009, 12:47 PM
Why do I get this error:

[MetadataException: Mapping for class 'atg001.BO.BLGBlogPost' is specified in file 'config' but the class could not be found.

I have searched through all files in the solution and I cannot find a reference of "atg001.BO". The file's name space is actually called btl001.BO.Blog.BLGBlogPost. WHere can I find this in which config and how do I change it.

10 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 28 Sep 2009, 08:14 AM
Hello Alec,

 Did you find my reply to the same problem ,posted in another thread in the forum, helpful?
Do let us know how we can help you further.

Kind regards,
Ady
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tom
Top achievements
Rank 2
answered on 02 Jan 2013, 10:24 AM
I'm hitting a very similar issue to this since changing the namespace of the project holding the orm project. however the link you've posted above doesnt work, could you relink the post or explain the steps to locate this config file and where it needs updating.
Thanks
Tom..
0
Ady
Telerik team
answered on 02 Jan 2013, 01:56 PM
Hello Tom,

 Are you using the 'Classic' product (mapping is in the app.config file) or are you using the domain model approach (.rlinq file)?
If you are using the classic approach you can use the 'Check Settings' dialog (Telerik->OpenAccess->Configuration->Check Settings menu entry) and run the checks and fix the resulting error. This error occurs because the <namespace name="xyz"...> node does not have the appropriate value. You verify this in the app.config file.

Greetings,
Ady
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Tom
Top achievements
Rank 2
answered on 02 Jan 2013, 07:48 PM
this is using .rlinq with your latest release.
0
Ady
Telerik team
answered on 03 Jan 2013, 02:21 PM
Hello Tom,

 Can you send me the .rlinq file so that I can try and reproduce the error and fix the file if required?

Kind regards,
Ady
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Tom
Top achievements
Rank 2
answered on 03 Jan 2013, 03:03 PM
Thanks,
I had already tried manually updating the file as .rlinq file still contained the old namespace however changing all references to the namespace to the new one did not resolve the issue so ive deleted and moved to the fluent api. I would still be interested in the steps you would have taken to resolve, if you still need the file I believe its relatively easy to reproduce so if needed I can create a file and send it to you.
Thanks
Tom.
0
Ady
Telerik team
answered on 03 Jan 2013, 03:34 PM
Hello Tom,

 It would be nice if you can send the .rlinq file so that I can see what the problem is. I would still expect that references to the old namespace still exist in the file, maybe they are just no visible in the designer.

Regards,
Ady
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Gary
Top achievements
Rank 1
answered on 25 Aug 2015, 07:59 PM

I am experiencing the same exception while using the FluentAPI. I have a class defined that derives from a base class which defines some common properties.

interface IModificationTracker
{
    DateTime CreatedDate { get; set; }
    String CreatedBy { get; set; }
    DateTime UpdatedDate { get; set; }
    String UpdatedBy { get; set; }
}
 
public abstract class ModelBase : IModificationTracker
{       
    public DateTime CreatedDate { get; set; }
    public String CreatedBy { get; set; }
    public DateTime UpdatedDate { get; set; }
    public String UpdatedBy { get; set; }
}
 
 
public class DeliverableType : ModelBase
{       
    public Int64 ID { get; set; }
    public String Label { get; set; }
    public String Description { get; set; }
}

 

I then map it to the underlying table ...

protected override IList<MappingConfiguration> PrepareMapping()
{
    List<MappingConfiguration> configurations = new List<MappingConfiguration>();
 
    #region DeliverableType
 
    MappingConfiguration<DeliverableType> typeMap = new MappingConfiguration<DeliverableType>();
    typeMap.MapType(model => new
    {
        deliverable_type_id          = model.ID,
        deliverable_type_label       = model.Label,
        deliverable_type_description = model.Description,
        created_date                 = model.CreatedDate,
        created_by                   = model.CreatedBy,
        updated_date                 = model.UpdatedDate,
        updated_by                   = model.UpdatedBy
 
    }).ToTable("deliverable_types");
    //
    // Identify contraints on fields
    typeMap.HasProperty(c => c.Label).WithVariableLength(100);      // nvarchar(100)
    typeMap.HasProperty(c => c.Description).WithInfiniteLength();   // nvarchar(MAX)
    //
    // Identify the Primary Key
    typeMap.HasProperty(c => c.ID).IsIdentity(KeyGenerator.Autoinc);
    //
    // Define when to update the CreatedDate and UpdatedDate timestamps
    typeMap.HasProperty(c => c.CreatedDate).IsCalculatedOn(DateTimeAutosetMode.Insert);
    typeMap.HasProperty(c => c.UpdatedDate).IsCalculatedOn(DateTimeAutosetMode.InsertAndUpdate);
 
    #endregion DeliverableType
     
 
    configurations.Add(typeMap);
    return configurations;
}
 

And make it available through the context ...

public partial class DbContext : OpenAccessContext
   {
 
       public IQueryable<DeliverableType> DeliverableTypes
       {
           get
           {
               return this.GetAll<DeliverableType>();
           }
       }
        
       // ... Connection configuration goes here
 
   }

 

Then when I attempt to add a new entity to the table ...

 

using (var ctx = new DbContext())
{
    DeliverableType newType = new DeliverableType
    {
        CreatedBy = "UNIT TEST",
        UpdatedBy = "UNIT TEST",
        Description = "TEST DESCRIPTION",
        Label = "TEST LABEL",
        CreatedDate = DateTime.Now,
        UpdatedDate = DateTime.Now
    };
 
    ctx.Add(newType);
    ctx.SaveChanges();
}

 

  I get the error ...

Telerik.OpenAccess.Exceptions.MetadataException: Mapping for field '<CreatedDate>k__BackingField' is specified in the file 'config', but the field is not present in the class 'InnovativeFoto.BLL.Models.DeliverableType'. --> FromMetadataContainer/namespace[InnovativeFoto.BLL.Models]/class[DeliverableType]/field[<CreatedDate>k__BackingField]​

 

Any thoughts on what could be causing this? I did everything according to the instructions. 

 

Here is the table schema if that helps ... 

CREATE TABLE [dbo].[deliverable_types](
    [deliverable_type_id] [bigint] IDENTITY(1,1) NOT NULL,
    [deliverable_type_label] [nvarchar](100) NOT NULL,
    [deliverable_type_description] [nvarchar](max) NULL,
    [created_date] [datetime] NOT NULL,
    [created_by] [nvarchar](100) NOT NULL,
    [updated_date] [datetime] NOT NULL,
    [updated_by] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_deliverable_types] PRIMARY KEY CLUSTERED
(
    [deliverable_type_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

0
Ady
Telerik team
answered on 28 Aug 2015, 02:43 PM
Hello Gary,

 You have forgotten to map the base class and the inheritance between the 2 types and hence you get that error. Telerik DataAccess is trying to find the field in the type and its defined in the base type.

Please have a look this documentation for mapping inheritance hierarchies.

Do get back in case you need further assistance.

Regards,
Ady
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
Gary
Top achievements
Rank 1
answered on 28 Aug 2015, 05:12 PM
DOH!! That was it! thank you!
Tags
General Discussions
Asked by
Alec
Top achievements
Rank 1
Answers by
Ady
Telerik team
Tom
Top achievements
Rank 2
Gary
Top achievements
Rank 1
Share this question
or