Problem adding new properties to database on .NET Core 3.1

17 Views Asked by At

I'm having a problem updating a new property (field) on a working database. I do not usually managed the SQL side of things and I am fairly new to some of the workings of database management with .NET core web development.

I have a database called ProSolution with a variety of fields that are linked to a ApplicationRequest model. The ProSolution db context has had a new field added that I am trying to add to the ApplicationRequest to update this database. The new field is called StudentDetailUserDefinedHealth1. I have ran update-database on all the Data/Contexts and no error is thrown when I push the ApplicationRequest to the database i.e. it accepts there is a field called StudentDetailUserDefinedHealth1 but the data never changes on the ProSolution db.

Here is some of the code for the process;

ApplicationRequest.cs

public string ResidenceAreaHesacode { get; set; }
public string PreferredPronounId { get; set; }
public bool? IsHomeFees { get; set; }
public int? HomeFeeEligibilityId { get; set; }
public string StudentDetailUserDefinedHealth1 { get; set; }

ApolloService.cs

if(myApp.ALS_EHCP == true)
                {
                    myApplicationRequest.StudentDetailUserDefinedHealth1 = "Declared";
                }
                else
                {
                    myApplicationRequest.StudentDetailUserDefinedHealth1 = "Not Declared";
                }
_ApolloProSoContext.ApplicationRequest.Add(myApplicationRequest);
_ApolloProSoContext.SaveChanges();
Log.Debug("App injected OK");
return "OK";

ProSolutionContext.cs

public partial class ApolloProSoContext : DbContext
    {
        public ApolloProSoContext()
        {
        }

        public ApolloProSoContext(DbContextOptions<ApolloProSoContext> options)
            : base(options)
        {
        }

        public virtual DbSet<ApplicationRequest> ApplicationRequest { get; set; }

    }
0

There are 0 best solutions below