views:

19

answers:

1

I have Visual Studio 2008:

  • I can create Entity Framework models on existing tables in a SQL Server 2005 database.
  • I can create Entity Framework models on tables I create in a local SQL Server 2008 database files.

However, when I add a new table to the SQL Server 2005 database, then try to create an Entity Framework model on it, it lets me click the little checkbox next to the table and finish, but the .edmx/...Designer.cs file consists only of four methods but nothing about the table that I selected, as if the I hadn't selected it.

  • What could be causing code not to be generated on the table I selected?
  • Where could I look for error messages regarding the attempted creation of code for this table?
+1  A: 

0) I think, you have added and then deleted this table before. In this case you should open model file (Designer.cs), remove all this table related records (manualy) and then refresh the model.

1) Maybe you have many-to-many relationship tables. EF decides no to add "link" table in this case.

2) Maybe you have a table that has two fields (PK and FK to other one) ONLY. In this case EF does the same.

3) Install later SP to VS and framework.

4) Check connection string.

igor
thanks but it doesn't even work for the simplest of tables, e.g. Id (PK), FirstName varchar(50), LastName FirstName varchar(50)
Edward Tanguay
I think, you have deleted this table before. In this case you should open model file, remove all this table related records (manualy) and then refresh the model.
igor
it's odd because it's a new database and new table: I can only imagine it has some kind of permission problem which allows it to show the table in the list, but not get its schema, etc.
Edward Tanguay
sa -> and go on! :)
igor
update: when I add a new table to an existing database, then it works, so it seems that there is some kind of setting in the new database that I created that I am not making which causes Entity Framework to not generate classes for any tables inside that database even after you check them to be included in the model
Edward Tanguay
Yes you are right. You can check the new one in the list of tables (those your model have not). EF does not automatically add new ones. And it is ok. Your model is not a snapshort of all tables. You can use some tables or views or don't. (if I understood you).
igor