I have an ASP.NET Core application that works correctly on my local machine but encounters an issue when deployed to an Azure Windows VM. Specifically, the model passed as a parameter to the POST method of WeeklyAllocations
is null. Interestingly, when I take a backup of the database from the VM’s SQL Server and restore it locally, the application works as expected.
Here’s a summary of the relevant code and configurations:
WeeklyAllocations.cshtml
@using ReSource_Management.Models.Interfaces
@model ReSource_Management.Models.ViewModels.ResourceAllocationViewModel
@inject IResourceAllocationRepository resources
@{
ViewData["Title"] = "Resource Allocations";
Layout = "~/Views/Shared/_Layout.cshtml";
// int availableHours = ViewBag.AvailableHours != null ? (int)ViewBag.AvailableHours : 0;
int availableHours = 40;
int weekId = Model?.WeekId ?? 0;
int i = 0;
int maxallocationhours = 50;
}
<form asp-action="WeeklyAllocations" method="post">
<div class="row align-items-center mb-3">
<a asp-controller="Home" asp-action="Dashboard" class="text-decoration-none col-auto">
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" width="25px" viewBox="0 0 52 52" enable-background="new 0 0 52 52" xml:space="preserve">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="3.0159999999999996"></g>
<g id="SVGRepo_iconCarrier">
<path d="M48.6,23H15.4c-0.9,0-1.3-1.1-0.7-1.7l9.6-9.6c0.6-0.6,0.6-1.5,0-2.1l-2.2-2.2c-0.6-0.6-1.5-0.6-2.1,0L2.5,25c-0.6,0.6-0.6,1.5,0,2.1L20,44.6c0.6,0.6,1.5,0.6,2.1,0l2.1-2.1c0.6-0.6,0.6-1.5,0-2.1l-9.6-9.6C14,30.1,14.4,29,15.3,29h33.2c0.8,0,1.5-0.6,1.5-1.4v-3C50,23.8,49.4,23,48.6,23z"></path>
</g>
</svg>
</a>
<h2 class="mb-0 col">Resource Allocation</h2>
<button type="submit" class="btn btn-RMT col-auto">Update Changes</button>
</div>
<div class="row mb-4 align-items-center">
<input type="hidden" asp-for="WeekId" value="@Model.WeekId" />
<h5 class="col m-0">Available Hours: @availableHours</h5>
<div class="col-auto">
<div class="row">
<a class="btn btn-outline-RMT w-auto me-2 p-0 align-content-center" asp-action="WeeklyAllocations" asp-controller="Resource" asp-route-Id="@resources.GetPreviousWeekId(weekId)">
<svg fill="#000000" width="30px" viewBox="0 0 24.00 24.00" xmlns="http://www.w3.org/2000/svg" transform="rotate(0)matrix(1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M13.41,12l3.3-3.29a1,1,0,1,0-1.42-1.42l-4,4a1,1,0,0,0,0,1.42l4,4a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42ZM8,7A1,1,0,0,0,7,8v8a1,1,0,0,0,2,0V8A1,1,0,0,0,8,7Z"></path>
</g>
</svg>
</a>
<input type="date" readonly class="form-control border-2 border-RMT p-1 text-center w-auto me-2 fw-medium" value="@Model.StartDateFormatted" />
<input type="date" readonly class="form-control border-2 border-RMT p-1 text-center w-auto me-2 fw-medium" value="@Model.EndDateFormatted" />
<a class="btn btn-outline-RMT w-auto me-2 p-0 align-content-center" asp-action="WeeklyAllocations" asp-controller="Resource" asp-route-Id="@resources.GetNextWeekId(weekId)">
<svg fill="#000000" width="30px" viewBox="0 0 24.00 24.00" xmlns="http://www.w3.org/2000/svg" transform="rotate(0)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M13.41,12l3.3-3.29a1,1,0,1,0-1.42-1.42l-4,4a1,1,0,0,0,0,1.42l4,4a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42ZM8,7A1,1,0,0,0,7,8v8a1,1,0,0,0,2,0V8A1,1,0,0,0,8,7Z"></path>
</g>
</svg>
</a>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-RMT">
<thead>
<tr class="text-center">
<th>Employee</th>
<th>Allocated %</th>
@foreach (var project in Model.Projects)
{
<th>@project.Name</th>
}
</tr>
</thead>
<tbody>
<tr class="text-center">
<td><strong>Hours Planned</strong></td>
<td id="sum-allocated">0</td>
@foreach (var project in Model.Projects)
{
<td id="[email protected]">0</td>
}
</tr>
@foreach (var user in Model.Users)
{
<tr class="align-items-center">
<td class="ps-2">@user.Name</td>
<td class="text-center sum-row" id="[email protected]">0</td>
@foreach (var project in Model.Projects)
{
<td>
<input type="number" name="Allocations[@i].AllocatedHours" class="form-control w-auto ms-auto me-auto p-1 text-center justify-content-center project-hours" data-user="@user.Id" data-project="@project.Id" min="0" max="@maxallocationhours" value="@resources.GetAllocations(user.Id,project.Id,weekId).ToString()" />
<input type="hidden" name="Allocations[@i].UserId" value="@user.Id" />
<input type="hidden" name="Allocations[@i].ProjectId" value="@project.Id" />
<input type="hidden" name="Allocations[@i].WeekId" value="@Model.WeekId.ToString()" />
@{
i++;
}
</td>
}
</tr>
}
</tbody>
</table>
</div>
</form>
ResourceAllocationViewModel.cs:
public class ResourceAllocationViewModel
{
public List<User> Users { get; set; }
public List<Project> Projects { get; set; }
public int WeekId { get; set; }
public DateOnly StartDate { get; set; } = new DateOnly();
public DateOnly EndDate { get; set; } = new DateOnly();
public List<WeeklyResourceAllocation> Allocations { get; set; }
public string StartDateFormatted => StartDate.ToString("yyyy-MM-dd");
public string EndDateFormatted => EndDate.ToString("yyyy-MM-dd");
public ResourceAllocationViewModel()
{
Users = new List<User>();
Projects = new List<Project>();
Allocations = new List<WeeklyResourceAllocation>();
}
}
ResourceController.cs:
public class ResourceController : Controller
{
private readonly IUserRepository _userRepository;
private readonly IProjectRepository _projectRepository;
private readonly IResourceAllocationRepository _weeklyResourceAllocationRepository;
private readonly IConfiguration _configuration;
private readonly UserInfo _user;
public ResourceController(
IUserRepository userRepository,
IProjectRepository projectRepository,
IConfiguration configuration,
IResourceAllocationRepository weeklyResourceAllocationRepository,
IUserSession userSession)
{
_userRepository = userRepository;
_projectRepository = projectRepository;
_configuration = configuration;
_weeklyResourceAllocationRepository = weeklyResourceAllocationRepository;
_user = userSession.GetUserInfoFromSession() ?? new UserInfo();
if (!IsValidUser(_user))
{
RedirectToAction("Login", "Account");
}
}
public ActionResult Index()
{
return View();
}
[HttpGet]
public async Task<IActionResult> WeeklyAllocations(int Id)
{
if (Id == 0 || !_weeklyResourceAllocationRepository.WeekExists(Id))
{
return RedirectToAction("WeeklyAllocations", new { Id = _weeklyResourceAllocationRepository.GetCurrentWeekId() });
}
var ra = new ResourceAllocationViewModel
{
WeekId = Id,
Users = await _userRepository.GetAllActiveEmployeesAsync(),
Projects = await _projectRepository.GetAllOngoingProjectsAsync(),
StartDate = await _weeklyResourceAllocationRepository.GetStartDateAsync(Id),
EndDate = await _weeklyResourceAllocationRepository.GetEndDateAsync(Id),
Allocations = new List<WeeklyResourceAllocation>()
};
ViewBag.AvailableHours = _configuration.GetValue<int>("FileSettings:WorkingHours");
ViewBag.WeekId = Id;
return View(ra);
}
[HttpPost]
public async Task<IActionResult> WeeklyAllocations(ResourceAllocationViewModel model)
{
if (model == null)
{
ModelState.AddModelError(string.Empty, "Invalid data submitted.");
ViewBag.AvailableHours = _configuration.GetValue<int>("FileSettings:WorkingHours");
return View(model);
}
foreach (var allocation in model.Allocations)
{
await _weeklyResourceAllocationRepository.SaveAllocationsAsync(allocation);
}
if (model.WeekId != 0)
{
return RedirectToAction("Report", new { Id = model.WeekId });
}
return RedirectToAction("WeeklyAllocations", new { Id = 0 });
}
}
ResourceAllocationRepository.cs:
public class ResourceAllocationRepository : IResourceAllocationRepository
{
private readonly ResourceManagementContext _context;
public ResourceAllocationRepository(ResourceManagementContext context)
{
_context = context;
}
public int GetAllocations(int userId, int projectId, int weekId)
{
var allocation = _context.WeeklyResourceAllocations.FirstOrDefault(a => a.UserId == userId && a.ProjectId == projectId && a.WeekId == weekId);
return allocation?.AllocatedHours ?? 0;
}
public async System.Threading.Tasks.Task SaveAllocationsAsync(WeeklyResourceAllocation weekAllocation)
{
await EnsureWeeksExistAsync();
var existingAllocation = await _context.WeeklyResourceAllocations
.FirstOrDefaultAsync(w => w.WeekId == weekAllocation.WeekId && w.UserId == weekAllocation.UserId && w.ProjectId == weekAllocation.ProjectId);
if (existingAllocation != null)
{
existingAllocation.AllocatedHours = weekAllocation.AllocatedHours;
_context.WeeklyResourceAllocations.Update(existingAllocation);
}
else if (weekAllocation.AllocatedHours != 0)
{
await _context.WeeklyResourceAllocations.AddAsync(weekAllocation);
}
await _context.SaveChangesAsync();
}
public async Task<DateOnly> GetStartDateAsync(int weekId)
{
var week = await _context.Weeks.FirstOrDefaultAsync(w => w.Id == weekId);
return week?.StartDate ?? DateOnly.MinValue;
}
public async Task<DateOnly> GetEndDateAsync(int weekId)
{
var week = await _context.Weeks.FirstOrDefaultAsync(w => w.Id == weekId);
return week?.EndDate ?? DateOnly.MinValue;
}
public async Task<int> GetCurrentWeekIdAsync()
{
var currentDate = DateOnly.FromDateTime(DateTime.Now);
var week = await _context.Weeks.FirstOrDefaultAsync(w => w.StartDate <= currentDate && w.EndDate >= currentDate);
if (week == null)
{
await EnsureWeeksExistAsync();
week = await _context.Weeks.FirstOrDefaultAsync(w => w.StartDate <= currentDate && w.EndDate >= currentDate);
}
return week?.Id ?? throw new Exception("No week found for the current date.");
}
private async System.Threading.Tasks.Task EnsureWeeksExistAsync()
{
if (!await _context.Weeks.AnyAsync())
{
var startDate = new DateOnly(2023, 12, 31);
await AddWeeksAsync(startDate, 100);
}
else
{
var maxWeekId = await _context.Weeks.MaxAsync(w => w.Id);
var lastWeek = await _context.Weeks.OrderByDescending(w => w.Id).FirstOrDefaultAsync();
if (lastWeek != null && lastWeek.Id - 5 < maxWeekId)
{
await AddWeeksAsync(lastWeek.EndDate.AddDays(1), 10);
}
}
}
private async System.Threading.Tasks.Task AddWeeksAsync(DateOnly startDate, int numberOfWeeks)
{
var weeks = new List<Week>();
var weekDate = startDate;
for (int i = 1; i <= numberOfWeeks; i++)
{
var endDate = weekDate.AddDays(6);
weeks.Add(new Week { Id = i, StartDate = weekDate, EndDate = endDate });
weekDate = endDate.AddDays(1);
}
await _context.Weeks.AddRangeAsync(weeks);
await _context.SaveChangesAsync();
}
public int GetCurrentWeekId()
{
return GetCurrentWeekIdAsync().GetAwaiter().GetResult();
}
public int GetNextWeekId(int currentWeekId)
{
var currentWeek = _context.Weeks.Find(currentWeekId);
if (currentWeek == null) return 0;
var nextWeek = _context.Weeks.FirstOrDefault(nw => nw.StartDate == currentWeek.EndDate.AddDays(1));
return nextWeek?.Id ?? 0;
}
public int GetPreviousWeekId(int currentWeekId)
{
var currentWeek = _context.Weeks.Find(currentWeekId);
if (currentWeek == null) return 0;
var previousWeek = _context.Weeks.FirstOrDefault(pw => pw.EndDate == currentWeek.StartDate.AddDays(-1));
return previousWeek?.Id ?? 0;
}
public bool WeekExists(int weekId)
{
return _context.Weeks.Find(weekId) != null;
}
}
ResourceManagementContext.cs:
public partial class ResourceManagementContext : DbContext
{
public ResourceManagementContext()
{
}
public ResourceManagementContext(DbContextOptions<ResourceManagementContext> options)
: base(options)
{
}
public virtual DbSet<Client> Clients { get; set; }
public virtual DbSet<Document> Documents { get; set; }
public virtual DbSet<Holiday> Holidays { get; set; }
public virtual DbSet<ManagerAssignment> ManagerAssignments { get; set; }
public virtual DbSet<Project> Projects { get; set; }
public virtual DbSet<ProjectAssignment> ProjectAssignments { get; set; }
public virtual DbSet<SkillSet> SkillSets { get; set; }
public virtual DbSet<Task> Tasks { get; set; }
public virtual DbSet<TaskAssignment> TaskAssignments { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<Week> Weeks { get; set; }
public virtual DbSet<WeeklyResourceAllocation> WeeklyResourceAllocations { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlServer("Name=DefaultConnection");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Client>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__Clients__3214EC07B6B0969F");
entity.HasIndex(e => e.ProjectId, "IX_Clients_ProjectID");
entity.Property(e => e.EmailId)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.Name)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.PhoneNumber)
.HasMaxLength(20)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.ProjectId).HasColumnName("ProjectID");
entity.HasOne(d => d.Project).WithMany(p => p.Clients)
.HasForeignKey(d => d.ProjectId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__Clients__Project__7EC1CEDB");
});
modelBuilder.Entity<Document>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__Document__3214EC27BAFAE224");
entity.HasIndex(e => e.UserId, "IX_Documents_UserId");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Name)
.HasMaxLength(255)
.IsUnicode(false);
entity.Property(e => e.Path)
.HasMaxLength(255)
.IsUnicode(false);
entity.HasOne(d => d.User).WithMany(p => p.Documents)
.HasForeignKey(d => d.UserId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__Documents__UserI__038683F8");
});
modelBuilder.Entity<Holiday>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__Holiday__3214EC0747F219C8");
entity.ToTable("Holiday");
entity.Property(e => e.AppliedTo)
.HasMaxLength(60)
.IsUnicode(false);
entity.Property(e => e.Description)
.HasMaxLength(150)
.IsUnicode(false);
});
modelBuilder.Entity<ManagerAssignment>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__ManagerA__3214EC27FA41C499");
entity.HasIndex(e => e.ManagerId, "IX_ManagerAssignments_Manager_ID");
entity.HasIndex(e => e.ProjectId, "IX_ManagerAssignments_Project_id");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.ManagerId).HasColumnName("Manager_ID");
entity.Property(e => e.ProjectId).HasColumnName("Project_id");
entity.HasOne(d => d.Manager).WithMany(p => p.ManagerAssignments)
.HasForeignKey(d => d.ManagerId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__ManagerAs__Manag__0662F0A3");
entity.HasOne(d => d.Project).WithMany(p => p.ManagerAssignments)
.HasForeignKey(d => d.ProjectId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__ManagerAs__Proje__075714DC");
});
modelBuilder.Entity<Project>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__Projects__3214EC07BA1686EC");
entity.Property(e => e.Budget).HasColumnType("decimal(10, 2)");
entity.Property(e => e.BudgetType)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.Country)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.EndDate)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.Property(e => e.Name)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.StartDate)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.Property(e => e.Status)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("Ongoing");
entity.Property(e => e.Type)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
});
modelBuilder.Entity<ProjectAssignment>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__ProjectA__3214EC075757B75C");
entity.HasIndex(e => e.MemberId, "IX_ProjectAssignments_MemberId");
entity.HasIndex(e => e.ProjectId, "IX_ProjectAssignments_ProjectId");
entity.HasOne(d => d.Member).WithMany(p => p.ProjectAssignments)
.HasForeignKey(d => d.MemberId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__ProjectAs__Membe__0B27A5C0");
entity.HasOne(d => d.Project).WithMany(p => p.ProjectAssignments)
.HasForeignKey(d => d.ProjectId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__ProjectAs__Proje__0A338187");
});
modelBuilder.Entity<SkillSet>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__SkillSet__3214EC07C595C206");
entity.ToTable("SkillSet");
entity.HasIndex(e => e.EmployeeId, "IX_SkillSet_EmployeeID");
entity.Property(e => e.EmployeeId).HasColumnName("EmployeeID");
entity.Property(e => e.Name)
.HasMaxLength(50)
.IsUnicode(false);
entity.Property(e => e.Proficiency)
.HasMaxLength(50)
.IsUnicode(false);
entity.Property(e => e.Type)
.HasMaxLength(50)
.IsUnicode(false);
entity.HasOne(d => d.Employee).WithMany(p => p.SkillSets)
.HasForeignKey(d => d.EmployeeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__SkillSet__Employ__0E04126B");
});
modelBuilder.Entity<Task>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__Tasks__3214EC0705FF8660");
entity.HasIndex(e => e.ProjectId, "IX_Tasks_ProjectId");
entity.HasIndex(e => e.TaskManagerId, "IX_Tasks_TaskManagerId");
entity.Property(e => e.Category)
.HasMaxLength(255)
.IsUnicode(false);
entity.Property(e => e.Description)
.HasMaxLength(255)
.IsUnicode(false);
entity.Property(e => e.Name)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.RequiredTime).HasColumnType("decimal(3, 2)");
entity.Property(e => e.TaskDate)
.HasDefaultValueSql("(getdate())")
.HasColumnType("datetime");
entity.HasOne(d => d.Project).WithMany(p => p.Tasks)
.HasForeignKey(d => d.ProjectId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__Tasks__ProjectId__10E07F16");
entity.HasOne(d => d.TaskManager).WithMany(p => p.Tasks)
.HasForeignKey(d => d.TaskManagerId)
.HasConstraintName("FK__Tasks__TaskManag__11D4A34F");
});
modelBuilder.Entity<TaskAssignment>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__TaskAssi__3214EC077F0AA659");
entity.HasIndex(e => e.AssignedTo, "IX_TaskAssignments_AssignedTo");
entity.HasIndex(e => e.TaskId, "IX_TaskAssignments_TaskId");
entity.Property(e => e.CompletedAt).HasColumnType("datetime");
entity.HasOne(d => d.AssignedToNavigation).WithMany(p => p.TaskAssignments)
.HasForeignKey(d => d.AssignedTo)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__TaskAssig__Assig__14B10FFA");
entity.HasOne(d => d.Task).WithMany(p => p.TaskAssignments)
.HasForeignKey(d => d.TaskId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__TaskAssig__TaskI__15A53433");
});
modelBuilder.Entity<User>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__Users__3214EC079F7F2BB6");
entity.Property(e => e.Designation)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.EmailId)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.EmployeementStatus)
.HasMaxLength(50)
.IsUnicode(false)
.HasDefaultValue("Active");
entity.Property(e => e.Gender)
.HasMaxLength(15)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.Name)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.Password)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.PhoneNumber)
.HasMaxLength(15)
.IsUnicode(false);
entity.Property(e => e.ProfileImagePath)
.HasMaxLength(255)
.IsUnicode(false);
entity.Property(e => e.Role)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
entity.Property(e => e.WorkLocation)
.HasMaxLength(255)
.IsUnicode(false)
.HasDefaultValue("");
});
modelBuilder.Entity<Week>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__Weeks__3214EC076CD604FE");
});
modelBuilder.Entity<WeeklyResourceAllocation>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__WeeklyRe__3214EC075F12AA39");
entity.ToTable("WeeklyResourceAllocation");
entity.HasIndex(e => e.ProjectId, "IX_WeeklyResourceAllocation_ProjectId");
entity.HasIndex(e => e.UserId, "IX_WeeklyResourceAllocation_UserId");
entity.HasIndex(e => e.WeekId, "IX_WeeklyResourceAllocation_WeekId");
entity.HasOne(d => d.Project).WithMany(p => p.WeeklyResourceAllocations)
.HasForeignKey(d => d.ProjectId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__WeeklyRes__Proje__1D4655FB");
entity.HasOne(d => d.User).WithMany(p => p.WeeklyResourceAllocations)
.HasForeignKey(d => d.UserId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__WeeklyRes__UserI__1C5231C2");
entity.HasOne(d => d.Week).WithMany(p => p.WeeklyResourceAllocations)
.HasForeignKey(d => d.WeekId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK__WeeklyRes__WeekI__1E3A7A34");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
ReSource_Management.csproj:
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>ReSource_Management</RootNamespace>
</PropertyGroup>
Despite the apparent correctness of my model binding and configurations, the issue persists only on the Azure VM environment. Here are some steps I’ve tried to resolve the issue:
- Confirmed that the database connection strings are correct.
- Ensured the database structure and data on the VM match the local setup.
- Added logging to verify the model state.
- Checked if the
AntiForgeryToken
is valid and included in the form. - Ensured that the model’s data is being correctly passed from the view.
However, the problem remains unsolved. Could there be any specific configuration or environmental factor on the Azure VM that might be causing this issue? Any insights or suggestions for further debugging steps would be greatly appreciated.
1