-1

I'm trying to generate a Generic Repository. So far, so good. But I get the same error as somebody else posted before: Mapping to a nested class

The problem is that I am apparently trying to map a nested class. How can I fix this, so I do not map a nested class anymore?

EDIT: That should not be the problem.

namespace MvcApplication1.Models
{
    public class MyContext :DbContext
    {

        public DbSet<ALBUM> Albums { get; set; }
        ...
}
}

where for example ALBUM:

[EdmEntityTypeAttribute(NamespaceName="MyDbModel", Name="ALBUM")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class ALBUM : EntityObject

Why is the class ALBUM not allowed to map?

Community
  • 1
  • 1
1408786user
  • 1,868
  • 1
  • 21
  • 39
  • You should *really* *really* post the error message you're getting, instead of making some sort of strange conclusion. Actually, I guess you should really read the error message first. – GregRos May 30 '12 at 20:58

2 Answers2

4

This is the error message you're getting.

System.InvalidOperationException: The type 'ContactModels+Contact' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject.

AND THIS is the class you're trying to map:

[EdmEntityTypeAttribute(NamespaceName="MyDbModel", Name="ALBUM")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class ALBUM : EntityObject

You're inherting from EntityObject. It says right there. You can't map it.

GregRos
  • 8,667
  • 3
  • 37
  • 63
1

Nested means you have a class inside a class, simply extract the nested class.

You probably have something like this:

public class SampleClass
{
      public class NestedClass
      {
      }
}

Change it to :

public class SampleClass
{}

public class NotNestedClass
{}
Preben Huybrechts
  • 5,853
  • 2
  • 27
  • 63
  • Thanks, in that case I don't have nested classes. See the update how my code works. So there should be another problem. Maybe the partial classes? – 1408786user May 30 '12 at 20:51