locked
Collision between T4 and LegacyObjectContext RRS feed

  • Question

  • Hello. I have an application that use EntityFramework 4. It was developing in VS 2010, but now I'm using VS 2013. The application work pretty fine till I start to change the database and trying to update model from database using EF 5. After model's updating I can not compile the solution. I think the reason is VS 2013 generate T4 classes instead of LegacyObjectContext. I've tried to change CodeGenerationStrategy property of the model file properties. But it doesn't help. Project still prompts errors during compilation (a lot of errors). How can I make VS 2013 to generate LecacyObjectContext classes during update model from database? How to resolve this issue?

    Appered errors looks like "metadate file coud not be found".

    Sunday, June 21, 2015 11:49 AM

Answers

  • Hello andriy.bilash,

    >>How can I make VS 2013 to generate LecacyObjectContext classes during update model from database?

    For generating ObjectContext in EF5, please follow these steps:

    1. Delete both .tt files from your project.

    2. In the Properties window change the Code Generation Strategy from None to Default.

    For details, you could refer to this link: https://msdn.microsoft.com/en-us/data/jj556581.aspx

    However, as DA924 mentions, it is recommended to use the new DbContext class which provides a better performance.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Fred Bao Monday, June 22, 2015 2:21 AM
    • Marked as answer by Fred Bao Wednesday, July 1, 2015 7:25 AM
    Monday, June 22, 2015 2:21 AM

All replies

  • But it doesn't help. Project still prompts errors during compilation (a lot of errors). How can I make VS 2013 to generate LecacyObjectContext classes during update model from database? How to resolve this issue?

    I suggest that you abandon this and go with DBcontext  from  now on. What you are talking about is a PITA and nothing but pure trouble. And I am talking from first hand experience. :)

    Sunday, June 21, 2015 7:45 PM
  • Hello andriy.bilash,

    >>How can I make VS 2013 to generate LecacyObjectContext classes during update model from database?

    For generating ObjectContext in EF5, please follow these steps:

    1. Delete both .tt files from your project.

    2. In the Properties window change the Code Generation Strategy from None to Default.

    For details, you could refer to this link: https://msdn.microsoft.com/en-us/data/jj556581.aspx

    However, as DA924 mentions, it is recommended to use the new DbContext class which provides a better performance.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Fred Bao Monday, June 22, 2015 2:21 AM
    • Marked as answer by Fred Bao Wednesday, July 1, 2015 7:25 AM
    Monday, June 22, 2015 2:21 AM