How to: OpenAccess to MVC 3

4 posts, 0 answers
  1. Matthew
    Matthew avatar
    16 posts
    Member since:
    Nov 2011

    Posted 07 Nov 2011 Link to this post

    First, I'm a rookie when it comes to MVC and I've never used any Telerik components.  I'm trying to build my first project and I'm hopelessly lost.  Previously I created a MVC 3 project using MvcScaffolding which creates the models, controllers and views for you.

    I wanted to use the Database first approach to creating my models.  Thus far I have completed the following

    1.  Created a Telerik MVC 3 (Razor) project
    2.  Added a Telerik Class project to my solution to create entity models from an existing database.
    3.  Successfully created the entities from my existing database
    4.  Added a reference in my client project to the model project and the two Telerik OpenAccess DLLs

    Now I'm stuck.  It appears the next step is to define a "database context" in some way so I can start creating the controllers but I'm at a loss what to do next.  I've spent two days looking at the videos, demos, etc. and I can't quite figure it out.

    I suspect this is easy and I'll slap myself once someone shows me how simple it is to do this.


     

  2. Matthew
    Matthew avatar
    16 posts
    Member since:
    Nov 2011

    Posted 08 Nov 2011 Link to this post

    I figured it out.  I think my confusion came from the use of words that appear to be used intercangeably including "Data Context", "Entities", or "Models".  I'm still pondering the best naming convention, but to me "Entities" should work given that when you perform an OpenAccess Database First conversion you end up with an "Entities" file.  No doubt someone will point out the terms are not synonymous.

    I have had some challenges with knowing when to reference the namespace (Model class project)  and when to use the "Data Context" reference, but I suppose that will come along the way as I stop simply copying code and start writing my own code.

    One of the nice things about MvcScaffolding is that it automatically creates defaut models, views, and controllers, from an existing database and puts them neatly in separate folders.  However, there isn't much support for making ad-hoc changes to the underlying database with touching a bunch of code or starting over.  I'm looking forward to the day with Telerik has a scaffolding solution that automatically uses the MVC Grid for the view.
       

  3. DevCraft banner
  4. Matthew
    Matthew avatar
    16 posts
    Member since:
    Nov 2011

    Posted 08 Nov 2011 Link to this post

    Perhaps there is a way to point MvcScaffolding at the generated entities and build controllers and views?
  5. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 09 Nov 2011 Link to this post

    Hi Matthew,

    Let me clear a bit the misunderstanding in terminology. Here is how we use it:

    - Domain Model: A set of concepts that describe the structure of the data, as persistent classes and relationships, regardless of its stored form.
    - OpenAccessContext: Represents the container defined in the conceptual model. It contains a connection to the underlying data source and provides services such as change tracking and identity resolution. An OpenAccessContext is represented by an instance of the OpenAccessContext class.
    - Entity - we usually use the term as a substitute of Domain Class, as a part of the Domain Model

    As for the MvcScaffolding, for the time being we do not have anything added to it's automation. However, you are free to use it to build your controllers and views based on the auto-generated OpenAccess classes, available in your Data Access Layer where the Domain Model is defined.

    Do not hesitate to get back to us for further clarifications.


    Regards,
    Ivailo
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

Back to Top