Im working with json and write the data same as the model, but still recieving the error 'System.InvalidOperationException: 'The given ColumnMapping does not match up with any column in the source or destination.'
my model code
public partial class VerTempWellTrajectory
{
[Key] public int No { get; set; }
public string? Well { get; set; }
public string? TrajectoryYesNo { get; set; }
public string? WellType { get; set; }
public string? Status { get; set; }
public string? FileAdviceToBeDigitized { get; set; }
public string? Remark { get; set; }
public DateTime? RowCreated { get; set; }
}
my json
function Save() {
var fail = {
title: 'Data insert fail',
message: 'refresh page to save again',
position: 'topRight'
};
console.log(_oSeismics);
if (_oSeismics.length > 0) {
var ajaxRequest = $.ajax({
url: "../DummyTempAdd/SaveDummyWT/",
type: "POST",
data: { data: _oSeismics },
dataType: "json",
beforeSend: function () {
},
});
ajaxRequest.done(function (data) {
alert("Successfully saved.");
});
ajaxRequest.fail(function (jqXHR, textStatus) {
iziToast.error(
fail
);
});
}
else {
iziToast.error(
fail
);
}
}
function NewSeismicObj() {
var now = new Date();
var date = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
var time = now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
var dateTime = date + ' ' + time;
console.log(dateTime)
var oSeismic = {
No: "",
Well: "",
TrajectoryYesNo:"",
WellType: "",
Status: "",
FileAdviceToBeDigitized: "",
Remark: "",
RowCreated: dateTime
};console.log(dateTime)
return oSeismic;
}
my controller
public JsonResult SaveDummyWT(List<VerTempWellTrajectory> data)
{
_WTt = _db.SaveDummyWT(data);
TempData["success"] = "Inserted to Temporary Table successfully";
return Json(_WTt);
}
i send from the controller to service file here is the service code
public List<VerTempWellTrajectory> SaveDummyWT(List<VerTempWellTrajectory> data)
{
_dbContext.BulkInsert(data);
return data;
}
on other process it run as it is, but in this model always recieving the error i mentioned down here I have the screenshot of the data passed from the json Data passed and the screenchot of tables design Table design
I add my modelbuilder code below
modelBuilder.Entity<VerDummyWellTrajectory>(entity =>
{
entity.ToTable("VER_DUMMY_WELL__TRAJECTORY", "db_owner");
entity.Property(e => e.FileAdviceToBeDigitized)
.HasMaxLength(512)
.IsUnicode(false)
.HasColumnName("FILE_ADVICE_TO_BE_DIGITIZED");
entity.Property(e => e.No)
.HasMaxLength(512)
.IsUnicode(false)
.HasColumnName("NO");
entity.Property(e => e.Remark)
.HasMaxLength(512)
.IsUnicode(false)
.HasColumnName("REMARK");
entity.Property(e => e.RowCreated)
.HasColumnType("datetime")
.HasColumnName("ROW_CREATED");
entity.Property(e => e.Status)
.HasMaxLength(512)
.IsUnicode(false)
.HasColumnName("STATUS");
entity.Property(e => e.TrajectoryYesNo)
.HasMaxLength(512)
.IsUnicode(false)
.HasColumnName("TRAJECTORY_Yes_No");
entity.Property(e => e.Well)
.HasMaxLength(512)
.IsUnicode(false)
.HasColumnName("WELL");
entity.Property(e => e.WellType)
.HasMaxLength(512)
.IsUnicode(false)
.HasColumnName("WELL_TYPE");
});