Thank you
await CurrentUnitOfWork.SaveChangesAsync();
flushes the changes to the database and now my queries are working appropriately without errors.
This issue has been resolved!
Dear alirizaadiyahsi, thank you for the reply.
Below are the fluent mappings for the two classes.
UserImportConfiguration
namespace MyCompanyName.AbpZeroTemplate.Configuration
{
using System.Data.Entity.ModelConfiguration;
using UserImport;
public class UserImportConfiguration : EntityTypeConfiguration<UserImport>
{
public UserImportConfiguration()
: this("dbo")
{
}
public UserImportConfiguration(string schema)
{
ToTable(schema + ".UserImports");
HasKey(x => x.Id);
Property(x => x.Id).HasColumnName("Id").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None);
Property(x => x.Position).HasColumnName("Position").IsRequired().HasColumnType("int");
Property(x => x.Last).HasColumnName("LastName").IsRequired().HasColumnType("nvarchar").HasMaxLength(50);
Property(x => x.First).HasColumnName("FirstName").IsRequired().HasColumnType("nvarchar").HasMaxLength(50);
Property(x => x.DepartmentId).HasColumnName("DepartmentId").IsRequired().HasColumnType("nvarchar").HasMaxLength(50);
Property(x => x.Date).HasColumnName("Date").IsOptional().HasColumnType("datetime");
Property(x => x.IdBadge).HasColumnName("IdBadge").IsOptional().HasColumnType("nvarchar").HasMaxLength(15);
Property(x => x.JobCodeId).HasColumnName("JobCodeId").IsOptional().HasColumnType("nvarchar").HasMaxLength(50);
Property(x => x.EmailAddress).HasColumnName("EmailAddress").IsOptional().HasColumnType("nvarchar").HasMaxLength(254);
}
}
}
UserImportPresentation
namespace MyCompanyName.AbpZeroTemplate.Configuration
{
using System.Data.Entity.ModelConfiguration;
using UserImport;
public class UserImportPresentationConfiguration : EntityTypeConfiguration<UserImportPresentation>
{
public UserImportPresentationConfiguration()
: this("dbo")
{
}
public UserImportPresentationConfiguration(string schema)
{
ToTable(schema + ".UserImportPresentations");
HasKey(x => new { x.UserImportId });
Property(x => x.Name).HasColumnName("Name").IsRequired().HasColumnType("nvarchar").HasMaxLength(66);
Property(x => x.Department).HasColumnName("Department").IsRequired().HasColumnType("nvarchar").HasMaxLength(103);
Property(x => x.JobCode).HasColumnName("JobCode").IsRequired().HasColumnType("nvarchar").HasMaxLength(103);
Ignore(x => x.Id);
HasRequired(x => x.UserImport);
}
}
}
Attached is the schema for both tables (see included image below).
I can comment out the UserImportPresentation insert statement and run the application the data will be added.
foreach (var import in imports)
{
await userImportRepository.InsertAsync(import);
// var presentationUser = BuildUserImportPresentationResult(import, departments, jobCodes);
// await userImportPresentationRepository.InsertAsync(presentationUser);
}
Next stop the application and fetch the UserImport records and I can then comment out the UserImport insert statement and run the application a second time and the data will be added.
var import = await userImportRepository.GetAllListAsync();
foreach (var import in imports)
{
// await userImportRepository.InsertAsync(import);
var presentationUser = BuildUserImportPresentationResult(import, departments, jobCodes);
await userImportPresentationRepository.InsertAsync(presentationUser);
}
The problem appears to be trying to insert the data on the same run, the second insert fails because the first is not in the table yet.
Hello,
Thank you for your reply. This issue was caused by a number of factors:
This is not a problem with the upgrade. If it is possible to add better error handling for this situation, we would be be very grateful.
Thank you.
Hello,
I apologize for the confusion, but yes. To be precise, we updated to the latest version of the "dev" branch in ASPNetZero here: https://github.com/aspnetzero/aspnet-zero/commit/683de0612490f512be79af464ec87e6f5e1bf3b6
Thank you for your help.
Thank you so much. This works!
We sent FTP credential information to <a href="mailto:[email protected]">[email protected]</a> this morning, Monday, March 6th, 2017 to access the project.
Hello, Sure as long as your email servers can accept a 20mb zip file or larger. Otherwise we may need somewhere to upload this project for you. Let us know if the email does not arrive. Thanks
Thanks for the quick reply.
When we encountered the issue we created a sample project to replicate using the latest version from the dev branch of aspnetzero/aspnet-zero (commit sha1 is bb2c66009d859afc5b466dbee228ba9e32bac9fb).
That works! Thank you.
Replaced contents of AbpZeroDbMigrator with TenantDbContext version.
namespace MyCompanyName.AbpZeroTemplate.EntityFramework
{
using Abp.Dependency;
using Abp.Domain.Uow;
using Abp.MultiTenancy;
using Abp.Zero.EntityFramework;
public class AbpZeroDbMigrator : AbpZeroDbMigrator<AbpZeroTemplateTenantDbContext, AbpZeroTemplateTenant.Configuration>
{
public AbpZeroDbMigrator(
IUnitOfWorkManager unitOfWorkManager,
IDbPerTenantConnectionStringResolver connectionStringResolver,
IIocResolver iocResolver) :
base(
unitOfWorkManager,
connectionStringResolver,
iocResolver)
{
}
}
}
Is there a way to override the IOC container registration to use our custom class AbpZeroTenantDbMigrator, instead of the replacing the contents of the AbpZeroDbMigrator?