Generate POCO classes from model using T4 templates vs. EF4.1 simplified API Model First approach

前端 未结 1 1929
庸人自扰
庸人自扰 2021-01-14 16:12

I have model created with visual designer. Now I want to have POCO classes generated from it. In another question of mine, EF4.1 simplified API Model First approach was sugg

相关标签:
1条回答
  • 2021-01-14 16:37

    EF 4.1 provides simplified API mostly glorified because of the code first approach available in EF for the first time. What you describe is the model first approach.

    I already answered similar question but I will try to answer your individual questions:

    • Main limitation of DbContext API is lack of information. We know new features but we still don't know how to achieve some features available in ObjectContext API (simplification probably removed some features). I'm not sure how this relate to the model first approch with DbContext generator T4 template because in this case mapping is still defined in EDMX file so some well known problems with the code first mapping should be overcome.
    • Generating database works automtic with DbContext API. ObjectContext API by default offers only db script generation and you must execute the script. On the other hand if you have VS 2010 Premium or Ultimate you can download Entity designer database generation power pack which will allow you building your database incrementaly without deleting it every time. That is something not possible with DbContext API at the moment.
    • You can have POCO classes (templates) in other project with both APIs.
    • Yes even with T4 template generating POCO classes you can use annotations.
    • No there is no difference in efficiency. DbContext API is just wrapper on top of ObjectContext API.
    0 讨论(0)
提交回复
热议问题