One or more validation errors were detected during model generation

Jun 4, 2012 at 11:28 PM

Im step by setp with the pdf. i dont know why im getting this

One or more validation errors were detected during model generation:

System.Data.Edm.EdmEntityType: : EntityType 'UrlHelper' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RequestContext' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'HttpContextBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Exception' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Type' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'AssemblyName' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'CultureInfo' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'DateTimeFormatInfo' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Calendar' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'IdentityReference' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RouteData' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RouteBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'ControllerContext' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'ControllerBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: Name: The specified name is not allowed: '__ConsoleStream'.
System.Data.Edm.EdmEntityType: : EntityType 'Encoding' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'TextWriter' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntitySet: : The referenced EntitySet �ActionResults� for End �ContentResult_ContentEncoding_Source� could not be found in the containing EntityContainer.
System.Data.Edm.EdmEntitySet: : The referenced EntitySet �ActionResults� for End �JsonResult_ContentEncoding_Source� could not be found in the containing EntityContainer.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �UrlHelpers� is based on type �UrlHelper� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RequestContexts� is based on type �RequestContext� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �HttpContextBases� is based on type �HttpContextBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Exceptions� is based on type �Exception� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Types� is based on type �Type� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �AssemblyNames� is based on type �AssemblyName� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �CultureInfoes� is based on type �CultureInfo� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �DateTimeFormatInfoes� is based on type �DateTimeFormatInfo� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Calendars� is based on type �Calendar� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �IdentityReferences� is based on type �IdentityReference� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RouteDatas� is based on type �RouteData� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RouteBases� is based on type �RouteBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ControllerContexts� is based on type �ControllerContext� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ControllerBases� is based on type �ControllerBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Encodings� is based on type �Encoding� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �TextWriters� is based on type �TextWriter� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ActionResults� is based on type �ActionResult� that has no keys defined.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.Entity.ModelConfiguration.ModelValidationException: One or more validation errors were detected during model generation:

System.Data.Edm.EdmEntityType: : EntityType 'UrlHelper' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RequestContext' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'HttpContextBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Exception' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Type' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'AssemblyName' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'CultureInfo' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'DateTimeFormatInfo' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Calendar' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'IdentityReference' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RouteData' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RouteBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'ControllerContext' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'ControllerBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: Name: The specified name is not allowed: '__ConsoleStream'.
System.Data.Edm.EdmEntityType: : EntityType 'Encoding' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'TextWriter' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntitySet: : The referenced EntitySet �ActionResults� for End �ContentResult_ContentEncoding_Source� could not be found in the containing EntityContainer.
System.Data.Edm.EdmEntitySet: : The referenced EntitySet �ActionResults� for End �JsonResult_ContentEncoding_Source� could not be found in the containing EntityContainer.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �UrlHelpers� is based on type �UrlHelper� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RequestContexts� is based on type �RequestContext� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �HttpContextBases� is based on type �HttpContextBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Exceptions� is based on type �Exception� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Types� is based on type �Type� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �AssemblyNames� is based on type �AssemblyName� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �CultureInfoes� is based on type �CultureInfo� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �DateTimeFormatInfoes� is based on type �DateTimeFormatInfo� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Calendars� is based on type �Calendar� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �IdentityReferences� is based on type �IdentityReference� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RouteDatas� is based on type �RouteData� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RouteBases� is based on type �RouteBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ControllerContexts� is based on type �ControllerContext� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ControllerBases� is based on type �ControllerBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Encodings� is based on type �Encoding� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �TextWriters� is based on type �TextWriter� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ActionResults� is based on type �ActionResult� that has no keys defined.


Source Error: 

Line 17:         public ActionResult Index()
Line 18:         {
Line 19:             var genres = storeDB.Genres.ToList();
Line 20:             return View(genres);
Line 21:         }

Jun 8, 2012 at 3:13 PM

Any help :|?

Coordinator
Jun 12, 2012 at 8:26 AM

Can you show the contents of your MusicStoreEntities.cs class? It looks like you're possibly including a DbSet of a controller class (e.g. StoreController), which is attempting to generate database tables based on the controller base class properties.

Jun 12, 2012 at 2:00 PM

 public class MusicStoreEntities : DbContext   

{       

//        // GET: /MusicStoreEntities/
        public DbSet<Album> Albums { get; set; }       

public DbSet<Genre> Genres { get; set; }       

public DbSet<Artist> Artist { get; set; }

    }

 

and the storeController

        MusicStoreEntities storeDB = new MusicStoreEntities();
        public ActionResult Index()        {            var genres = storeDB.Genres.ToList();            return View(genres);        }

Coordinator
Jun 12, 2012 at 3:15 PM

Okay, it looks like you're somewhere in section 4, and that some of the code above is in the wrong file. Can you look at the section 4 save point in the Save Points download and compare your code? http://mvcmusicstore.codeplex.com/downloads/get/233892