locked
DBDomainService & DbContext RIA Class Library, EF 5 RRS feed

  • Question

  • Dear All,

    I am using EF5, Silverlight, RIA Service in a project.

    I have a RIA class library project (with the two projects), I have setup everything correctly for the other SL projects to the class library.

    I created .EDMX in RIA .web project for the database and I got the following class generated:

    public partial class SCEntities : DbContext
    {
         public SCEntities()
             : base("name=SCEntities")
        {
        }
    
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }
    
        public DbSet<period> periods { get; set; }
        public DbSet<user> users { get; set; }
    }
    

    In my client SL application, I can't get a reference to the DbContext class (SCEntities).

    I created a DomainService Class in the RIA Class .web project it inherit the DBDomainService (as previous EF4) as follows:

    public partial class SCDomainService : DbDomainService<SCEntities>
    {
    }

    I go back to my SL application & I can reference the SCDomainService with no problem.

    Why I can not reference or access the SCEntities (dbcontext) ?

    Is it right to go with the DomainService?

    Best.

    Monday, November 14, 2016 10:23 AM

All replies

  • Hi Paladin2k,

    >>Why I can not reference or access the SCEntities (dbcontext) ?

    Could you please provide a bit more information, such as screen shot, detailed error message.

    In addition, about WCF data Service with Silverlight, please refer to the following document.

    https://msdn.microsoft.com/en-us/library/ee621313.aspx

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 15, 2016 9:34 AM
    Moderator
  • Dear Cole,

    Thanks for your reply,

    following, I will show you my project structure.

    This are RIA Class Library with the previous class

    public partial class SCEntities : DbContext

    {

         public SCEntities()

             : base("name=SCEntities")

        {

        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)

        {

            throw new UnintentionalCodeFirstException();

        }

        public DbSet<period> periods { get; set; }

        public DbSet<user> users { get; set; }

    }

    following is the content of the details of the two projects.

    The Red is the class I need to reference from other SL projects.

    The Yellow is the generated client file (doesn't contain any reference to SCEntities.

    The Green is the class I created, which I used to do on EF4, which allow me to query the database.

    My question again, why I can't get reference to the SCEntities....

    Best


    Waleed Seada

    Saturday, December 3, 2016 11:44 AM