Dylan Czenski
Dylan Czenski

Reputation: 1375

Cannot generate ADO.NET Entity Data Model, model class is empty

So I follow all the steps to create the ADO.NET Entity data model, right click the Model folder, click Add New Item -> ADO.NET Entity Data model -> Generate from Database, and then select the database connection and enter the namespace of my models, and click Finish. However the edmx view looks like this:

enter image description here

I built the solution, still the same. And after the build, the model class is not generated, I can only see:

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

There is no class definition is found here. I checked SQL Server, the table and its data are there. What have I missed?

Upvotes: 0

Views: 1739

Answers (2)

Jordi Prat
Jordi Prat

Reputation: 141

The table or view does not have a primary key defined and no valid primary key could be inferred. For this reason, this table or view has been excluded. To use the entity, you will need to review your schema, add the correct keys.

Upvotes: 1

Dylan Czenski
Dylan Czenski

Reputation: 1375

If your table has been accidentally removed, add it back to the DBML file and recreate the ADO.NET Entity Data model.

Upvotes: 0

Related Questions