Hello
I am on my first EF6 project and I have couple of questions
Project outlines
Property (Building) have Rooms
A Room have list of criteria or rating
Each criteria own a set of values
i.e.
Property (Building) A have
Room 1
Each room have bunch of values
Value a 0-1
Value B 2-5 ... etc.
Room 2
Each room have bunch of values
Value a 1-3
Value B 0-5 ... etc.
Property (Building) B have
Room 1
Each room have bunch of values
Value a 0-1
Value B 4-9
Value c 0-1 ... etc.
Room 2
Each room have bunch of values
Value a 1-3
Value B 0-4 ... etc.
...
Therefore, by nature a property (Building) have a list of rooms, each room have its own values
Therefore, the database design is
Property 1...N Rooms
Rooms 1...N Values
These values can be modified on desire
I am using EF6 to handle the DB, and Caliburn.Micro BindableCollection
Pulling the data from the DB using DbSet
Now, the dilemma is to save the Rooms and its values without duplication, I tried updating the dbSet using the loops but that only caused data duplication.
I could not find a way to empty the DbSet from its data without reverting to spaghetti code, which I’m trying to avoid
My Question is How to save the data to the DB without
1- Duplication
2- Spaghetti and very ugly code
3- Dropping the frameworks I am using
thanks in advance
What I have tried:
Empty DBContext and its DbSet
Convert ICollection to DbSet
Saved successfully but with Duplicated data