この種のことを試した後:プロパティレベルの属性を追加して、実行時に ColumnAttribute をマップする方法は? 別の問題が見つかりました。
その理由は、DataContext の同じインスタンスを再利用したいからです。しかし、変更後に DataContext を更新したい場合、ArgumentException '同じキーを持つ要素が既に追加されています' が発生します。私はこれまでにこれを試しました:
FieldInfo field = DataContext.Mapping.GetType().GetField("metaTables", BindingFlags.NonPublic | BindingFlags.Instance);
Dictionary<Type, MetaTable> metaModels = field.GetValue(DataContext.Mapping) as Dictionary<Type, MetaTable>;
metaModels.Remove(typeof(MyClass)); //Remove the class that I've modified
DataContext.Mapping.GetTable(typeof(MyClass)); //ArgumentException