I am using EntityFramework 6.1.3, Visual Studio 2012 and SQL Server 2008. In my case, the database has 125 tables and 3 of the tables do not have primary keys.
Is there a way I can add the tables without primary keys to my EDMX model in EF?
I am using EntityFramework 6.1.3, Visual Studio 2012 and SQL Server 2008. In my case, the database has 125 tables and 3 of the tables do not have primary keys.
Is there a way I can add the tables without primary keys to my EDMX model in EF?
The following page from MSDN describes an approach for Creating an Entity Key when no Key is Inferred however there is also an important note which says:
Changes made to the SSDL section of an .edmx file, as suggested in the procedures below, will be overwritten if you use the Update Model Wizard to update your model. To avoid manually editing the .edmx file in this case, modify your database schema so that each table has a primary key or so that one or more columns of each table or view is non-nullable or non-binary.
So -- if what you meant by 'not problematic in the future' involves being able to freely update your EDMX from the database schema without always repeating your manual changes for allowing the non-PK tables, then you have a problem.
You have to decide to either add PKs to these tables OR you'll have to continue to make manual updates to model after you update it from the DB schema.