none
Doubts about DBContext RRS feed

  • Question

  • Hi,

    I've been studying EF and, It's not clear for me some things about the object context. I'd like to create a repository class and then the context must be generic because in the future I can chance the tecnologic, instend EF to NHibernate or to test too. Because of this, I'd like to have a Interface where the EF context or any context can implement.

    Implementing this interface, I'd like to use code first developing the poco classes using data annotations and or fluent api I don't want to use the  edx file.

     

    Is it possible to do it? Or is there another maner much more simple and clean than that idea?

    Can someone help me?

    Thank you very much!

    Carlos 

    Friday, January 20, 2012 10:01 AM

Answers

  • Hi Carlos Marchi,

    Welcome to MSDN Forum.

    When you use code-first, you need to define a context which inherited from DBContext, you can also define some interfaces and make the context inherited from the interfaces.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 24, 2012 5:59 AM
    Moderator

All replies

  • Do you mean you want the context inherited from an interface?
    Tuesday, January 24, 2012 3:17 AM
  • Hi Carlos Marchi,

    Welcome to MSDN Forum.

    When you use code-first, you need to define a context which inherited from DBContext, you can also define some interfaces and make the context inherited from the interfaces.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 24, 2012 5:59 AM
    Moderator