Thanks @maliming for your response.
But fortunately by changing the dropdown DOM element name in _CreateModal.cshtml fixed one of the issues : name="EnterpriseClients[]"
Now I can see the dropdown and associate OU with EnterpriseClients as well. Both models are as below :
public class OrganisationUnit : OrganizationUnit
{
// https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=11109&hilit=extend
public virtual bool HasMultipleClients { get; set; }
public OrganisationUnit() { }
public OrganisationUnit(int? tenantId, string displayName, long? parentId = null) : base(tenantId, displayName, parentId) { }
public IList<OrganisationUnitEnterpriseClient> OrganisationUnitEnterpriseClients { get; set; }
}
// Third entity that contains mapping between OrganizationUnit(OU) and EnterpriseClient(EC)
public class OrganisationUnitEnterpriseClient
{
public long OrganisationUnitId { get; set; }
public OrganisationUnit OrganisationUnit { get; set; }
public int EnterpriseClientId { get; set; }
public EnterpriseClient EnterpriseClient { get; set; }
}
DashboardDbContext.cs => OnModelCreating method to define many to many relationship for both entities:
modelBuilder.Entity<OrganisationUnitEnterpriseClient>()
.HasKey(ouec => new { ouec.OrganisationUnitId, ouec.EnterpriseClientId });
With code in original section and above model setup, I am able to save an OU with one or many clients in the database like below:
X.Dashboard.Application\Organizations\OrganizationUnitAppService.cs
public async Task<OrganizationUnitDto> CreateOrganizationUnit(CreateOrganizationUnitInput input)
{
var organizationUnit = new OrganisationUnit(AbpSession.TenantId, input.DisplayName, input.ParentId);
await _organizationUnitManager.CreateAsync(organizationUnit);
if (input.EnterpriseClients != null && input.EnterpriseClients.Count > 0)
{
if (input.EnterpriseClients.Count > 1) { organizationUnit.HasMultipleClients = true; }
else { organizationUnit.HasMultipleClients = false; }
organizationUnit.OrganisationUnitEnterpriseClients = new List<OrganisationUnitEnterpriseClient>();
// Set mapping between OrganizationUnit and selected EnterpriseClient(s)
foreach (int enterpriseClientId in input.EnterpriseClients)
{
var link = new OrganisationUnitEnterpriseClient()
{
EnterpriseClientId = enterpriseClientId,
OrganisationUnitId = organizationUnit.Id,
EnterpriseClient = await _enterpriseClientRepository.GetAsync(enterpriseClientId),
OrganisationUnit = organizationUnit
};
organizationUnit.OrganisationUnitEnterpriseClients.Add(link);
}
}
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<OrganizationUnitDto>(organizationUnit);
}
Here, my extended class has 's' in the name : OrganisationUnit and the Abp class is OrganizationUnit. For the edit modal I am not sure about the required code change. How to update Dtos and Input models etc. to first show existing relationship between OU and EC - EnterpriseClient and then how to update it? If it was a regular dropdown then using premitive property it could be done hopefully.
But as its a multiselect dropdown plus no example found on the internet or this forum unfortunately that can give some hint on how to achieve that?
Seemed some browser caching issue. I am not able to login in Chrome browser but I can login via Firefox. To test finally I tried cleaning cache and gave a try in 'Edge' browser and surprisingly it worked! Now its working in Firefox also but not in Chrome. So hopefully full system restart may fix any caching issues!
To fix this error, I found that ef is not by default included in .NET 3.0 onward releases. So, if we are using .NET Core 3.x then we have to add ef tool packages additionally unlike .NET Core 2.2.
Below were my first two steps in CI pipeline of Azure DevOps but these can be anywhere before the efcore-migration-script-generator task.
steps:
...
all other the tasks.
But later I found that this is not a proper way of CI. I created CI using YAML but not using classical editor option as mentioned in the guide. And due to that I am having zip files, XMLs and cmd batch files as well in the artifact which should not be.
But for lot of developers the problem starts from .NET Core 3.x onwards!