none
EF ObjectContex inheritance problem RRS feed

  • Question

  • Hi All.

    I have one problem with conceptual model of EF.

    I have 2 ObjectContex classes.

    class Base : ObjectContext

    ...

    class Child : Base

    ...

    For these context classes I create DomainSerivce classes and link from Silverlight project.

    When I rebuild this Silverlight  project in my local machine, it's build correctly, but in other machine build is crushed with error:

    Error 462 Could not find the conceptual model type for 'Child.Foo'.

    Tuesday, April 17, 2012 10:31 PM

Answers

  • Hi Allen

    Yes first in my computer it's build, but when I re-install VS 2010, now it's not build in my computer.

    I solve that installing VS SP1. I think in other machine VS SP1 not exist.

    About object context.

    I write T4 template for EF code generation.

    In T4 template I change Base context constructors.

    In Child EF T4 template Child context inherit from Base context.

    In Child EF conde generation part I eliminate dublicate ObjectEntity class generation part.

    Now it's work great.

    Monday, April 23, 2012 12:01 PM

All replies

  • Hi Shrek_1985,

    Welcome to MSDN Forum.

    Does the other machine has something different with yours? Does the project you built in the other machine as same as worked project in your machine?


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, April 19, 2012 3:05 AM
    Moderator
  • Hi Shrek_1985,

    Have you solved the issue? I look forward to hearing from you.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 23, 2012 3:30 AM
    Moderator
  • Hi Allen,

    Thank's for Your responce

    I think this problem from EF inheritance.

    I add inheritance from one EF context to other EF context.

    For example

    I have Base EF context and corresponding objectEntity classes.

    And Child EF context inhered from Base class.

    When I create Child object it's call Base class default constructor and use Base class DB connection string and Base EF edmx file metadata.

    I think problem in this part.

    Now I try change Child and Base classes constructors and try to send connection string from Child class constructor to Base class constructor.

    I think it's will work.

    Whot you think about that?.


    • Edited by Shrek_1985 Monday, April 23, 2012 7:34 AM
    Monday, April 23, 2012 7:32 AM
  • Hi Shrek_1985,

    In the first post, you mentioned you can build it correctly in your machine, but can't build it in another machine, if the context inheritance has something wrong, I think it will not build success in your computer too. I'm not clear about the schema of your project, but IMO, calling base constructor in your child class to pass the connection string will help you to have the same metadata information in your two context.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 23, 2012 7:42 AM
    Moderator
  • Hi Allen

    Yes first in my computer it's build, but when I re-install VS 2010, now it's not build in my computer.

    I solve that installing VS SP1. I think in other machine VS SP1 not exist.

    About object context.

    I write T4 template for EF code generation.

    In T4 template I change Base context constructors.

    In Child EF T4 template Child context inherit from Base context.

    In Child EF conde generation part I eliminate dublicate ObjectEntity class generation part.

    Now it's work great.

    Monday, April 23, 2012 12:01 PM
  • Hi Shrek_1985,

    I'm glad to hear that you have solved the issue.

    Have a nice day!


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, April 25, 2012 5:06 AM
    Moderator
  • Hi Allen,

    Thank's for Your reply.

    About metadata duplication, I think it's not bad.

    For clear about my project schema, I can send you sample project.

    Wednesday, April 25, 2012 7:53 AM