オーチャードの migration.cs ファイルを使用して、データベース テーブルに列を追加しました。actionresultでその列の値を挿入すると、 この値はデータベースに表示されませんでした。Null 値のみが表示されます。これは、UpdateFromX メソッドを使用して migration.cs ファイルでテーブルを変更すると発生します
これには何か方法がありますか?
テーブルを変更するコードは次のとおりです:-
public int UpdateFrom19()
{
SchemaBuilder.AlterTable("EmpPartRecord", table => table.AddColumn<string>("Firstname", c => c.WithDefault( EmpPartRecord.Firstname).WithLength(1024)));
return 20;
}
Actionresult によって Firstname 列の値を挿入している間、 null を database に送信します。
**ActionResult コードはこちら:-
public ActionResult CreateNewEmp(string id, string nam, string add, string s)
{
try
{
var News = Services.ContentManager.New("Emp");
var obj = News.As<EmpPart>();
obj.empno = Convert.ToInt32(id);
obj.empnam = nam;
obj.empad = add;
obj.empsl = Convert.ToInt32(s);
obj.DateOrdered = DateTime.Now.ToString();
obj.phone = "96402";
obj.Lastname = "hello";
obj.Firstname = "hello";
Services.ContentManager.Create(obj);
}
catch (Exception hj)
{
}
return View();
}