none
cannot access import function using context after creating one for complex type RRS feed

  • Question

  • Hi,

    I've added a SP in my entity and an Import function is also created.


    public partial class MoneyProEntities : DbContext
        {
            public MoneyProEntities()
                : base("name=MoneyProEntities")
            {
            }
        
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                throw new UnintentionalCodeFirstException();
            }
        
            public DbSet<Installment> Installments { get; set; }
            public DbSet<Transaction> Transactions { get; set; }
        }

    nothing is coming in OnModelCreating. and I can't see method GetMeterValues in context object of my entity.

    Can anybody please tell me where am I wrong here?

    Tuesday, May 27, 2014 6:20 PM

Answers

  • Hello Parag,

    I am trying to help look into it. From your description, I am confused why the SP is not imported into the DbContext as below,:

    public partial class DFDBEntities : DbContext
    
        {
    
            public DFDBEntities()
    
                : base("name=DFDBEntities")
    
            {
    
            }
    
        
    
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
    
            {
    
                throw new UnintentionalCodeFirstException();
    
            }
    
        
    
            public virtual DbSet<Order> Orders { get; set; }
    
        
    
            public virtual ObjectResult<ProGetOrder_Result> ProGetOrder()
    
            {
    
                return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ProGetOrder_Result>("ProGetOrder");
    
            }
    
        }
    

    >>nothing is coming in OnModelCreating.

    It seems that you are working with database first approach, then the OnModelCretating wouldn’t be changed whatever we do with the model.

    >>and I can't see method GetMeterValues in context object of my entity.

    This is because it does not generate the correspondent method in your context class as above. And this is the key point, we need to find out why it does not generate it. For this, could you please share that what EF version you are working with, what your SP is? And could you find the complex type class file under yourModel1.tt, it should be GetMeterValues_Result.cs in your case?

    Also, please have a try to import other SPs to your model to and try to create a new project with a new .edmx model to import the SP which will not generate the correspondent method to the new model to check if they are the same result.

    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.

    Thursday, May 29, 2014 2:36 AM
    Moderator

All replies

  • Thanks for your question, Parag. I'm moving it to a more appropriate forum.

    Esther Fan | Visual Studio | If a post answers your question, please mark it as the answer. Thanks!


    Wednesday, May 28, 2014 4:33 PM
  • Hello Parag,

    I am trying to help look into it. From your description, I am confused why the SP is not imported into the DbContext as below,:

    public partial class DFDBEntities : DbContext
    
        {
    
            public DFDBEntities()
    
                : base("name=DFDBEntities")
    
            {
    
            }
    
        
    
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
    
            {
    
                throw new UnintentionalCodeFirstException();
    
            }
    
        
    
            public virtual DbSet<Order> Orders { get; set; }
    
        
    
            public virtual ObjectResult<ProGetOrder_Result> ProGetOrder()
    
            {
    
                return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ProGetOrder_Result>("ProGetOrder");
    
            }
    
        }
    

    >>nothing is coming in OnModelCreating.

    It seems that you are working with database first approach, then the OnModelCretating wouldn’t be changed whatever we do with the model.

    >>and I can't see method GetMeterValues in context object of my entity.

    This is because it does not generate the correspondent method in your context class as above. And this is the key point, we need to find out why it does not generate it. For this, could you please share that what EF version you are working with, what your SP is? And could you find the complex type class file under yourModel1.tt, it should be GetMeterValues_Result.cs in your case?

    Also, please have a try to import other SPs to your model to and try to create a new project with a new .edmx model to import the SP which will not generate the correspondent method to the new model to check if they are the same result.

    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.

    Thursday, May 29, 2014 2:36 AM
    Moderator