I noticed that yet no one implemented start DB structure using Code-First.
Here is an example:
We have model Log (Id, Message)
and we have model A1 (Id, Name, ICollection<Log> Logs)
When you have only A1 then EF Migration script will create A1_Id in Log table
Problem happens when we have a lot of Models with ICollection<Log> Logs
because each model will add own "_Id" column to Log Table.
Is there a way to implement this structure/tables
A1 (Id, Name, ... , ICollection<Log> Logs)
A2 (Id, Name, ... , ICollection<Log> Logs)
....
A102 (Id, Name, ... , ICollection<Log> Logs)
Log (Id, Message, OwnerId)
and so every time we need Logs for record in A77
EF will do this (select * from Log where OwnerId = 'id of record from A77')
I also don't want to create 102 foreign key constrains.
Does anyone know how to do this? I guess it has to be somehow done in protected override void OnModelCreating(DbModelBuilder modelBuilder)
method.