[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
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,
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.
Thanks
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
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
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.
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
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
]
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