0

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?

5
  • which DB and which EF version do you use? Commented Jun 1, 2016 at 14:30
  • @magicandre1981 Microsfot SQL Server Enterprise Edition (64-bit) version 11.0.6020.0, EF 4.0 (Runtime Version v4.0.30319) Commented Jun 1, 2016 at 14:38
  • ok, looks like use the old ObjectSet API. Don't do this. Use DBContext API (DbSet) by installing EF 6.1.3 via Nuget to your project: nuget.org/packages/EntityFramework/6.1.3, compile it 1 time and now run the wizard to generate model from db Commented Jun 1, 2016 at 15:04
  • @magicandre1981 Thanks but I don't think that is the problem since I create another ADO.NET entity model from another table, everything works perfectly. Commented Jun 1, 2016 at 15:23
  • even if it works for other tries, you should still no longer use the old API. It will be removed from EF-Core 1.0 Commented Jun 2, 2016 at 14:26

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.