I have an existing Ef DbContext (ApplicationDbContext) that connect to a MySql server with it's proper OnConfiguring and OnModelCreating function.
Now I must add a new DbContext (GeoDbContext) to a different server.
I add the GeoDbContext in services
.AddDbContext<ApplicationDbContext>(m => m.UseMySql(ApplicationConn, ServerVersion.AutoDetect(ApplicationConn)))
.AddDbContext<GeoDbContext>(m => m.UseNpgsql(GeoConn))
In the GeoDbContext, with its own OnConfiguring and OnModelCreating function, I defined a new DbSet property
public DbSet<UserLocation> Locations { get; set; }
Then I exec the Add-Migration , and this is my problem. Specifying I want to use the GeoDbContext
Add-Migration addLocation -Context GeoDbContext
I receive an error about properties existing in the ApplicationDbContext, already correctly configured in the ApplicationDbContext OnModelCreating function.
The entity type (omissed) has multiple properties with the [Key] attribute. Composite primary keys can only be set using 'HasKey' in 'OnModelCreating'.
I want add a migration only for the GeoDbContext. How to correctly configure it?