0

I have a requirements where we are supposed to store all the key-value in one table. For example, status of application, status of user requests, status of incident etc. We don't want to create separate tables for each type of statuses.

Now, with one table containing all the keys, let's say another table stores user and it's request details that requires us to have two columns in userRequest table to have two keys. Not sure how to achieve this in EF core, code-first approach.

Also, we don't want to add any navigational properties in the key-value table as otherwise it will grow very huge in future.

I tried some online tutorials, but they seems very old and those solutions aren't working anymore.

Thanks.

7
  • What database are you using? Commented Nov 8, 2023 at 23:09
  • I am using SQL Server Commented Nov 8, 2023 at 23:10
  • "Also, we don't want to add any navigational properties in the key-value table as otherwise it will grow very huge in future." - Navigation-properties only exist in the C# code, they don't impact the CREATE TABLE statements unless you aren't defining your FKs correctly and instead rely on EF to implicitly create those for you (which is always a bad idea) - but this is why Code-First is a bad idea for serious projects where the details of the design of the database matter. Is there a reason you can't (or won't) use a database-first approach (e.g. with SSDT) and use EF's scaffolding instead? Commented Nov 8, 2023 at 23:11
  • @Dai no reason as such, but this is something I have to work with, can't control. Commented Nov 8, 2023 at 23:12
  • @TechTurtle Then tell your boss/client/PM that you need to shift the project to be database-first and need 1-or-2 days for that. You (and they) won't regret it. Commented Nov 8, 2023 at 23:13

0

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.