VistaDB 6
VistaDB / Getting Started / Using VistaDB with Entity Framework / Using VistaDB with Entity Framework - Getting Started
In This Topic
    Using VistaDB with Entity Framework - Getting Started
    In This Topic

    Using VistaDB with Entity Framework is very similar to using EF with any other database. 

     Step One: Create Your VistaDB Database

    Because VistaDB only supports the Database-First model of creating an Entity Model for EF the first step is to create a VistaDB database with the schema  you want to start with.  If you change it later you can update the Entity Model easily to accommodate the changes.

    If you are converting to VistaDB from another database platform use the Database Migration Wizard to convert your reference schema to get a starting database.

    If you are starting a new project check out Getting Started - Creating A Database for the options to create a new database and edit the schema.  Once you have your basic tables and relationships in place you can proceed to the next step.

     Step Two: Registering the VistaDB Entity Framework Provider

    Before creating your Entity Model with VistaDB the VistaDB Entity Framework Provider needs to be registered with the project where you are going to add your entity model.  When using EF 4-5 this step is optional but necessary before you can deploy your application.  With EF 6 it's required before you will be given the option of generating a model from a VistaDB database. 

    If you are using Entity Framework 6 (or later) you will need to add EF from NuGet before proceeding.  This will register the latest Entity Framework libraries with your project which replace the ones that ship with the .NET framework. 

    To register the VistaDB EF Provider, see Using VistaDB with Entity Framework - Registering the Provider and then be sure to build your application before proceeding to step three.

     Step Three: Creating your Entity Model

    To create a new Entity Model:

    1. Within your Visual Studio project select Add->New Item.
    2. Select ADO.NET Entity Data Model from the list of items to add and click Add to start the Wizard.
    3. In the Choose Model Contents step select EF Designer from database and click Next.  This indicates to the wizard you want to use the Database-First model approach.
    4. Select the existing Data Connection from the list or click New Connection... and set up the connection to reference the database you created in Step One.  If you do not see the VistaDB 6 File provider in the Data Source list then review Step Two above - the Entity Framework Wizard couldn't find the VistaDB 6 provider.
    5. In the Choose Your Database Objects and Settings wizard step indicate which tables, views, and stored procedures you want to import for the initial model.  You can add more later (running through this same basic wizard).  Click Finish to create the model.  Depending on the complexity of your model and the number of tables it may take from several seconds to several minutes for the wizard to generate the initial model, during which Visual Studio will be unresponsive.
    6. The new model will be added to your project and, once you compile your project, will be ready for use. 

    See Also