First of all, to get the study. I have already seen and applied the solution in the answer to this question here: Does Web Deploy / Publish add an unknown connection string?
This does not work, and I mean that it does not affect the problem that I am facing.
Other information that may help is that I am working on Visual Studio 2015 Enterprise.
Well, now the problem I am facing is strange. I have two DB connections in my file web.config. They are defined as follows:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Test.mdf;Initial Catalog=Test;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="ErpConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\Test.mdf;Initial Catalog=Test;Integrated Security=True" providerName="System.Data.SqlClient" />
The context associated with DefaultConnectionis ApplicationDbContext. And the context associated with ErpConnectionis ErpEntityContext. Each of them is defined as follows:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("name=DefaultConnection")
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
and
public class ErpEntityContext : DbContext
{
public ErpEntityContext()
: base("ErpConnection")
{
}
}
However, the web deployment decides that ApplicationDbContextit DefaultConnectionshould be two very different, so it ends up showing them as two different connections, as in the image below:

Removing DefaultConnectionfrom web.configgets rid of double entry (this is obviously not a solution, since I would like to have a connection string). Changing the name of the connection string does not matter at all. This also does not occur with ErpConnection.
Visual Studio . , VS. , , , . , . , , - , .
EDIT:
, , , .
, Remove additional files at destination checked unchecked. , Exclude files from the App_Data folder checked unchecked, , (:)). .
UPDATE:
, Loaded DbConfiguration:
Loaded += (sender, args) => args.ReplaceService<DbProviderServices>((s, _) => new CachingProviderServices(s, transactionHelper, new ExampleCachingPolicy()));
:
EF , DbConfiguration , . / , . , , , .
, , . , , - , .