0

I am trying to learn Entity Framework. In the book that I am using, it guides me to creating a C# class library to house the entity framework model. Inside of this class library, I am instructed to add a new item and generate an ADO.NET Entity Data Model from an existing database (.NET 4).

After generating the classes, what I noticed is that the EntityObject classes were missing methods (like OnCustomerIDChanged, OnDueDateChanged, etc.). The classes only had property accessors and navigation properties. I did notice some files with .tt extensions. It looks like there is a new way of dealing with objects in Entity Framework but as I am still learning EF, I'm wondering if there is a way to bring it back to generating the missing methods? Thanks in advance for your help.

BTW, I tried using Visual Studio 2010 and it did create the methods I mentioned above. However, I'm wondering if it's possible make Visual Studio 2012 do the same since I've grown to like VS 2012.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670

1 Answers1

1

If you want to follow the book you should use VS 2010. EF has evolved and EntityObject based entities are considered obsolete.

Anyway if you want to force VS 2012 to behave in the same way as VS 2010 open your EDMX and in Properties Window change Code generation strategy to Default and save your EDMX file. After that you can delete all .tt files. All your entities will be generated in single .Designer.cs file.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Thank you very much, Ladislav. That solved my problem. As a side question and to guide my studies, what technique or technology replaced EntityObjects or how the code is generated? – ManilaMocha Jan 03 '13 at 03:15
  • POCO classes are used instead of `EntityObject` based entities and the code is generated through T4 templates (.tt files). – Ladislav Mrnka Jan 03 '13 at 09:15