Hi Arthur!
Thank you very much for your different approaches!
ObjectContext: After I spend much time to shift to DbContext, first I want to try PropertyChange in DbContext. Another reason is, that at the website you are posted, there are many comments, that it's not working correctly; so I'am a little bit deterred.
T4-Templates changing:
I don't like to change the templates, because after every entity framework-update I have to do it again. But still I tried this way and I got a couple of errors without thighter informations. (Additionally, the newer templates looks a little bit different, which may cause the problem?)
First, we could create a ViewModelBase, which implements INotifyPropertyChanged. After that, we could define all tables(=entities) (e. g. customer) as a partial classes again and could implement the :ViewModelBase.
When I copy the automatically generated customer.cs from the tt-file into my own cs-file and comment it out, the program is still running. After that, I can extend the customer.cs so that the PropertyChanged is rising, while adding it to each field-setter. Then it works.
It is most appreciated.
Best regards,
leveloper
Thank you very much for your different approaches!
ObjectContext: After I spend much time to shift to DbContext, first I want to try PropertyChange in DbContext. Another reason is, that at the website you are posted, there are many comments, that it's not working correctly; so I'am a little bit deterred.
T4-Templates changing:
I don't like to change the templates, because after every entity framework-update I have to do it again. But still I tried this way and I got a couple of errors without thighter informations. (Additionally, the newer templates looks a little bit different, which may cause the problem?)
The third link also doesn't solves the PropertyChange-Problem for us, but now I considered the following solution:1.) Which approach is the right? I tried the first one and considered the comment at the end of the page.
2.) It's possible for your team, in the new release of the Entity Framework, to insert these lines automatically in the template, when a special switch will be set? So for many developers this might be a very easy and fast way to use PropertyChanged. Second, after updating to a newer T4-Template, no developer has to care about these modifications again.
- to copy the automatically generated code from all tables(=entities) (e. g. customer.cs) out ouf the MyModel.tt in an own cs-file and
- to add the key-data-annotations to the necessary fields
- to copy the automatically generated Db-context out of the MyModel.Context.cs in an own cs-file.
Another way D:3.) After this, it's possible to run the application in Code-First without further modifications?
First, we could create a ViewModelBase, which implements INotifyPropertyChanged. After that, we could define all tables(=entities) (e. g. customer) as a partial classes again and could implement the :ViewModelBase.
Another way E:4.) Is it possible in each self defined partial table(=entity-class) (e. g. customer) to implement a behaviour that a field-modification of any field raises the PropertyChange?
When I copy the automatically generated customer.cs from the tt-file into my own cs-file and comment it out, the program is still running. After that, I can extend the customer.cs so that the PropertyChanged is rising, while adding it to each field-setter. Then it works.
Thank you very much!5.) After I do this, EF asks, the table was modified outside the Generator and if it has to be loaded again. Whatever I click: no or yes, it will be generated again. (After clicking yes once, the Messagebox doesn't asks again?) Why will the code created when I click "no"? / How will I see this Messagebox in future again?
6.) Can you change the behaviour of the EntityFramework in future, that the cs-file for this class (e. g. customer.cs) is not created again, when it's commented out completely?
It is most appreciated.
Best regards,
leveloper