私のモデルには、たとえばデータベースに3つのプロパティと対応するテーブルを持つモデルクラスがあります。例えばprop1
とprop3
を使用して作成しEFコードでモデルクラスを拡張するためのクラスを最初に作成する
public partial class Person
{
public string prop1 {set; get;}
public string prop2 {set; get;}
public string prop3 {set; get;}
}
今、私が派生するプロパティ:
prop4 = prop1 + prop3;
は私がprop4
を持っているPerson
を拡張したいです。私はprop4
を持っているPerson
のための部分クラスを作成します。
public partial class Person
{
public string prop4 {set; get;}
}
が、私は、私はこのエラーを得たアプリケーションを実行すると:
public class PersonViewModel : Person
{
public string prop4 { get; set; }
}
:
Invalid column name 'prop4'
を私はこのような上記のクラスを変更します
Invalid column name 'Discriminator'.\r\nInvalid column name 'Discriminator'.\r\nInvalid column name 'Discriminator'.\r\nInvalid column name 'prop4'
このようなクラスを作成しても、すべての考えは正常になります。
public class PersonViewModel
{
public string prop1 {set; get;}
public string prop2 {set; get;}
public string prop3 {set; get;}
public string prop4 {set; get;}
}
このソリューションを使用すると、ViewModelクラスのすべてのプロパティを書き換える必要があります。他の方法はありますか?
おかげ