none
Schema specified is not valid. Errors: The relationship not loaded because the type is not available. RRS feed

  • Question

  • I have the entities Dependency, Product and Access. Dependency is connected to Product and Access. When i try to create a object set of Access with:

    this.context.CreateObjectSet<Access>(); 

    It's working... but when i try to create a object set of Product i get this error: Schema specified is not valid. Errors: The relationship 'Model.FK_Product_Dependency' was not loaded because the type 'Model.Dependency' is not available.

    Any ideas?

    OBS: i'm working with Database to Model, and with EF 4.0

    POCO Entities:

    public class Dependency 
    { 
       
    public virtual int Id { get; set; } 
       
    public virtual int IdParent { get; set; } 
       
    public virtual string Name { get; set; } 
       
    public virtual decimal Type { get; set; } 
       
    public virtual Dependency Parent { get; set; } 
    } 
     
    public class Product 
    { 
       
    public virtual int Id { get; set; } 
       
    public virtual int IdDependency { get; set; } 
       
    public virtual decimal Type { get; set; } 
       
    public virtual string Name { get; set; } 
       
    public virtual string Obs { get; set; } 
       
    public virtual Dependency Dependency { get; set; } 
    } 
     
    public class Access 
    { 
       
    public virtual int Id { get; set; } 
       
    public virtual int IdProfile { get; set; } 
       
    public virtual string Name { get; set; } 
       
    public virtual Profile Profile { get; set; } 
       
    public virtual ICollection<Dependency> Dependencies { get; set; } 
    } 

    Caso esse post foi útil para você não esqueça de "Votar como Útil". =)
    Tuesday, January 31, 2012 2:26 PM

Answers

  • Solved. So, the POCO entities cannot be in different namespaces/dlls if access each other. In the exemple above, Dependency and Access was in a namespace/dll and Product in another. I thought that was only necessary the POCO entity be the same (properties and name) like the entity mapped by EF, but is necessary that the entities are in the same namespace/dll (only to the entities that access each other). 


    Caso esse post foi útil para você não esqueça de "Votar como Útil". =)
    Tuesday, January 31, 2012 6:41 PM

All replies

  • Solved. So, the POCO entities cannot be in different namespaces/dlls if access each other. In the exemple above, Dependency and Access was in a namespace/dll and Product in another. I thought that was only necessary the POCO entity be the same (properties and name) like the entity mapped by EF, but is necessary that the entities are in the same namespace/dll (only to the entities that access each other). 


    Caso esse post foi útil para você não esqueça de "Votar como Útil". =)
    Tuesday, January 31, 2012 6:41 PM
  • Hi Vinicius,

    Thanks for sharing your experience here!

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 1, 2012 1:19 AM
    Moderator