I was walking through some sample MVC applications I found on the web today, by trying to create them myself step by step. Even though I was following the steps explained in them very closely and accurately, I still could not get the Entity Data Model classes to get generated automatically in my application. In other words, even though I would create the sample database as described and the Model, I could not get the Entities to show up in the designer or the Model classes to get created.
I found out that if the tables in the database I am trying to generate a Model for, do not have a Primary Key defined on one of the columns, the EF will not be able to generate classes for the tables in that Database.
The Tutorials that I was walking through for learning MVC using EF did not mention this point.
So this was an important discovery I made and thought I might share with it others who may experience the same problem, in case they are new to EF.
Yeah, I've been burnt with this same problem. I think even LINQ requires you to have a primary key, which can be easily forgotten if you are just making a 'hello world' app to test the confines and abilities of a certain concept.
ReplyDelete