Reputation: 4434
I have a wpf project 4.5 and I am using EF 5 to generate the model classes. I want to implement iNotifyPropertyChanged for the EF classes gererated. So I right clicked in my designer (visual studio 2012) and changed the code generation setting from "None" to "Default"
Once I did that I got hundreds of errors like the following:
Error 67 'Public Property "TableColumnName" As "ColumnType" has multiple definitions with identical signatures.
[EDIT 1]
These errors are all being thrown in the DataModel.Designer.Vb file. They occur on any table column property or navigation property that have the same name as a column/navigation property in another table. I find it hard to believe that I can't have columns in different tables with the same names, something else must be going on here.
[EDIT 2]
So I removed all my database objects from the designer, then changed the code generation strategy to default, then added one table (client) to the diagram. I am getting lots of errors for every property of the table (so this must not be because other tables have the same column names as I previously thought). I am getting the error I listed above on EVERY property(table column) as well as the following error for EVERY property:
Error variable '_ColumnName' conflicts with a member implicitly declared for property 'ColumnName' in class 'client'. C:...\FTC_DAL.Designer.vb
This goes away when I return the code generation back to none. I am staring to think this is a bug in EF 5.
[EDIT 3]
STEPS TO REPRODUCE:
I am using:
I am going to install sql server 2012 express to see if this makes any difference
Can someone help me figure out why these errors are happening.
Thanks
Upvotes: 5
Views: 4735
Reputation: 71
Refer the following link. I spent a lot of time getting frustrated with this issue and found this support article from the link that shows up on the 'add domain service class' screen right after 'Some ... may be missing'...
The summary of the observation is that WCF RIA does not support DBContext (indicated by the .tt files). To use the Domain service class, ObjectContext classes are needed. Here's the resolution from the support article.
In order to utilize your Entity Framework model with WCF RIA Services, you must convert it to an 'ObjectContext' based model. This can be done using the following steps:
- Open your entity model in the designer
- (If needed, click in the "white space" of the designer to ensure no objects within the model are selected)
- In the Properties window, change the "Code Generation Strategy" from "None" to "Default"
- Delete the two ".tt" files that are adjacent to the model, with the assumption that you have not modified these files beyond their original state when the entity model was created. If you have modified these files, then customizations to your entity model will be lost.
- Rebuild the project
After following those steps, you will be able to select your entity model's context class in the 'Available context classes' list. The side-effect of this procedure is that you have now converted your entity model from an Entity Framework DbContext-based model to an ObjectContext-based model.
Upvotes: 7
Reputation:
Having the Code Generation Strategy at "None" is correct, you should leave it like that.
When you change it to "Default", you get classes for all the entities in your model. However, you are already getting those same classes from the .tt
templates. As a result, you're getting all the class members twice.
In order to change how the classes get generated, still leave Code Generation Strategy at "None", as the default code generation is not customisable anyway. The Model.tt
file can be freely modified to suit your needs, and it should not take too much effort to modify that to make your classes implement any interface you want.
Upvotes: 5