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:
- Create new project in Visual Studio 2012, wpf application.
It can be vb or c, i tested both - Add a ADO.NET entity data model (edmx file)
- Add a table from a sql server (I am using express 2008 R2)
- Build the project and then click in the edmx designer on blank space. In properties window, change code generation strategy to default instead of none.
- Build project and the errors will appear.
I am using:
- visual studio 2012 pro v.11.0.51106.01 update 1
- .NET 4.5.50709
- Windows 8 pro
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
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
.tttemplates. 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.ttfile 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.