Orcas Beta 1 ADO.NET vNext First Look

What is ADO.NET vNext or Entity Framework? It has been a long journey for the application development and data access. Starting from DLib,… DAO, ADO, ADO.NET. Now the world is for ADO.NET vNext or Entity Framework model. This is to increase the level of abstraction and avoid the change mismatch. In Orcas the designer is available for wizard. Let us see how we can leverage that,


Create a Windows Application using Orcas Beta 1. Then from the Solution Explorer add “ADO.NET Entity Data Model”.


Then choose the option “Generate From database”.



Then point to the database you are targeting.



Then choose the Tables  


Now add GridView and a Button (to load the data from database). Add the following code in your ButtonClick event. You have to use using NorthwindModel;


private void button1_Click(object sender, EventArgs e)


    NorthwindEntities db = new NorthwindEntities();

    var q = from c in db.Customers

            select c;

    dataGridView1.DataSource = q.ToList();


Now you run the apps to see the output.


Let me explain you what it is. It creates couple of files when you use wizard for Entity. In the file Model1.cs it creates a context class with the name NorthwindEntities and we have to initialize this class with the connection string. By default it takes the connection string located in Apps.config (which gets there while choosing the database).


You can add search queries like,


var q = from c in db.Customers

        where c.City == txtCity.Text

        select c;

In txtCity you can pass dynamic input at runtime.


Hope you have enjoyed this.