EF CTP5 INotifyPropertyChanged [英] EF CTP5 INotifyPropertyChanged
问题描述
首先使用代码时,我确实得到了一个没有实现INotifyPropertyChanged的实体。我得到:
public 部分 班级 员工
{
public int EmployeePkId { get ; set   ;; }
对于WPF开发,似乎实体应该实现INotifyPropertyChanged 接口。我设法改变了tt模板,但是这样做的方法是什么?我使用的是MVVM模式。
微软是否正在考虑提供另一个tt-template,这对我来说会这样做?
有什么意见吗?
干杯哈利
Harry,
我们打算用DbContext T4模板保存我们生成的类非常简单。
这有助于保持T4模板和生成的类易于理解,从而使人们可以更容易地以人们可能想要修改它们的任何方式修改它们。
因此,我认为你修改T4以在每个班级需要时添加INotifyPropertyChanged的方法是合理的。
(您还可以考虑使用部分类来添加此类附加功能。)
我们目前还没有任何计划来创建新的T4模板,这些模板将为您完成此任务,但未来可能会发生变化,特别是如果我们收到大量反馈请求。
谢谢,
Arthur
When using code first, I do get an entity which does not implement INotifyPropertyChanged. I get:
public partial class Employee
{
public int EmployeePkId { get; set ; }
For WPF development it seems that the entities should implement the INotifyPropertyChanged interface. I have managed to change the tt-template, but is this the way to do? I use the MVVM-Pattern.
Is Microsoft considering providing another tt-template which will do that for me?
Any comments?
Cheers Harry
Harry,
We intend to keep the classes that we generate with the DbContext T4 templates very simple. This helps keep both the T4 templates and the classes that are generated easy to understand, which in turn makes it easier for people to modify them in any of the many ways that people may want to modify them. Therefore I think your approach of modifying the T4 to add INotifyPropertyChanged if you need it on every class is reasonable. (You could also look into using partial classes to add additional functionality like this.) We don’t have any plans currently to create new T4 templates that will do this for you, but that may change in the future, especially if we get a lot of feedback asking for it.
Thanks,
Arthur
这篇关于EF CTP5 INotifyPropertyChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!