Hack Forums
[.NET] No key when using Entity Framework - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] No key when using Entity Framework (/showthread.php?tid=6125020)



No key when using Entity Framework - Kαѕρer - Dec 2, 2020

So I'm building a web application where I have a table without a primary key. In the past I always did builder.hasNoKey since that was supported for .NET Core 3.0.

Now the application is built in .NET Core 2.2 which means builder.hasNoKey isn't supported.

Is there any solution to this except from adding a primary key?

This is the exact error I'm getting: "The entity type 'XXX' requires a primary key to be defined."


RE: No key when using Entity Framework - Rmdy - Dec 3, 2020

Can we have a peek from your entity class? It might be an issue in the class and not in the database being without PK.