View Single Post
  #1 (permalink)  
Old November 1st, 2013, 04:37 AM
welshfella23 welshfella23 is offline
Registered User
 
Join Date: Oct 2013
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default problem - Professional ASP.Net MVC 4

Hello,
I wonder if some nice generous person could point me in the right direction with a problem I am having while working through the book: Professional ASP.Net MVC 4.
I have gotten to page 78 where I am instructed to create a new controller, ok no problem, but when I follow the instruction to select New Data Context, when I click add, I get an error thrown back at me in the form of:

Unable to retrieve metadata for 'MvcMusicStore.Models.Album'. One or more validation errors were detected during model generation:

-System.Data.Entity.Edm.EdmEntityType: : EntityType 'Album' has no key defined. Define the key for this EntityType.
-System.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'Albums' is based on type 'Album' that has no keys defined.


What I don't understand is, from what I am reading, the book says Visual Studio via Entity Framework is supposed to create the (database)table according to the existing code, it isn't something that pre exists and has been improperly designed. Am I wrong in assuming that the database model should be created based on the classes I have created?

Yes, I have set up the classes required as per the books instructions, but it looks like there is something severely flawed in the book, unless I have missed something which I honestly don't think I have.

Any pointers here would be greatly appreciated thank you.
Reply With Quote