I have solution with structure like this:
Solution
'-Project1
'-Model1.cs
'-MainDataContext.cs
'-Project2
'-Model1.cs
'-MainDataContext.cs
- Project1 and Project2 are simple assemblies
- Project2 references Project 1
- Both Project1 and Project 2 uses Entity Framework Core 2.2
- Project2.Model1.cs is derived from from Project1.Model1.cs
- Project2.MainDataContext is derived from Project1.MainDataContext
- Both assebmlies will have their own migrations
My plan is to have 2 separate apps where first will be using Project1 assembly and second Project2 assembly. Most (like 98%) of the data-model and business logic will be the same and we can say that Project1 is the "reference" one.
If I add some field specific for Project2 into Poject2.Model1 class and call the Add-Migration on Project2 assembly, the additional field is not detected and empty migration C# script is generated.
EDIT:
In Project1.MainDataContext I've declared:
public virtual DbSet<Model1> Model { get; set; }
In Project2.MainDataContext I've declared:
using Model1 = Project2.Model1;
...
public virtual DbSet<Model1> Model { get; set; }
At running Add-Migration I get Every concrete entity type in the hierarchy needs to have a unique discriminator value. error (which totally makes sense).
Is there possibility to extend Project1.Model1 with Project2.Model1 so there will be 2 separate migrations in both Project1 and Project2 but the table name in DB will be the same for both types?