Skip to main content Skip to footer

Using the Entity Framework C1DataSource in Visual Studio 2012

With the new release of Visual Studio now widely available there is a good chance that many of you may already be using it or will be migrating over to it in the not too distant future. If one leaves aside the all caps menu and somewhat less colourful UI, most things in Visual Studio 2012 work in much the same way as they did in Visual Studio 2010. As a result porting existing projects from 2010 to 2012 is a relatively painless experience. However, there have been some changes in the way that it works with the Entity Framework and those changes mean that for the present when building an Entity Data Model for use with the Studio for Entity Framework in Visual Studio 2012 (or if you rebuild a model in 2012 imported from 2010) you need to perform a couple of extra tasks before you will be able to use the created Object Context with a C1DataSource. This will not be necessary once you get an update for Studio for Entity Framework that will soon be available. But if you need to use the current version of SEF (version number less than 4.0.20123) in Visual Studio 2012, you can do it with simple steps below. Begin by creating the entity Data Model as you normally would;

  1. From the Project menu select Add New Item
  2. From the available choices in the Add New Item Dialog select ADO.Net Entity Data Model
  3. Follow the steps in the Entity Data Model Wizard, making sure that you have checked the Save entity connection settings in App.Config box.
  4. When the wizard has completed, you will be left with the Entity Data Model Diagram. Build the project at this stage.
  5. Now in the Solution Explorer click the show all files button.
  6. With that done expand the model1.edmx node, and delete the two files that you will see within that node with .tt extensions.
  7. Now right click on the surface of the Model Diagram and select properties.
  8. In the properties window locate the Code Generation Strategy Property and change it from its default setting (‘None’) to ‘Default’.
  9. Now rebuild your project.

That’s it. You can now use the C1DataSource as you always have done in Visual Studio 2010.

MESCIUS inc.

comments powered by Disqus