MVC and Entity Framework : Unable to retrieve the metadata for the model

Let’s say you are developing an MVC application and you want to add a generated controller with the associated views.

You do this:

  1. Setting the controller’s name
  2. Choosing the template: mvc controller with read/write actions and views, using Entity Framework
  3. Choosing the model class
  4. Choosing the data context
  5. Clicking “Add”

image001

It’s possible that you get this error:

image002

The solution is quite simple:

Just go in the web.config file and comment the connection string

image004

Then try again

image005

It works!

Don’t forget to uncomment your connection string and you are done.

Incoming search terms:

  • unable to retrieve metadata for model class
  • MVCandEntityFramework:Unabletoretrievethemetadataforthemodel
  • unable to retrieve metadata for
  • unable to retrieve metadata for model
  • unable to retrieve metadata for mvc
  • unable to retrieve metadata
  • entity framework unable to retrieve metadata
  • asp net mvc unable to retrieve metadata
  • mvc unable to retrieve metadata
  • yhs-fullyhosted_003

Quick tip: list all poco’s properties and their values

Let’s say you have a poco and you want to list all its properties whith their values for debug purpose (or other purposes : logs, …)

You can write something like this :


string porperties = "property1 : " + this.property1;
porperties+="property : " + this.property2;
// ..
porperties+="propertyn : " + this.propertyn;

but it’s long and painful, plus you can forget some properties

The reflection can help us here :


string porperties = "";
 foreach (System.Reflection.PropertyInfo f in this.GetType().GetProperties())
 {
porperties += f.Name + " : " + f.GetValue(this, null) + Environment.NewLine;
 }

And if you want to be a bit clever, you create a base object and redefine the ‘ToString() method like this:


public class POCOBase
{
public override string ToString()
{
string ret = "";
foreach (System.Reflection.PropertyInfo f in this.GetType().GetProperties())
{
ret += f.Name + " : " + f.GetValue(this, null) + Environment.NewLine;
  }
  return ret;
 }
}

Then just inherit from POCOBase and call the ToString() method

The output should be something like this :

AccountID : 10
ExternalREF : 090xfe
FIRSTNAME : USER 1
LASTNAME : TEST
PHONE : 00044440000
RegisterDate : 30/09/2009 16:20:02
Remark :

I think it’s quick, easy and useful

Visual Studio Default Key binding posters

Update 2015 : if you are looking for the 2012, 2013 or 2015 version : you can check this site : http://visualstudioshortcuts.com/

The visual studio 2010 keybinding poster is available since a few weeks.

Visual C# 2010 default key bindings preview :

VS2010CsharpKeyBinding1

VS2010CsharpKeyBinding2

Shortcuts are grouped by category (debuging, refactoring, editing, navigation, …)

Here is the Visual Studio Keyboard shortcuts posters for C#:

Visual Studio 2010

Visual Studio  2008

Visual Studio 2005

Enjoy them !

Incoming search terms:

  • Visual Studio 2013 Keybinding Posters
  • Visual Studio 2012 Keybinding Posters
  • visual studio 2013 shortcuts poster
  • visual studio 2012 shortcuts
  • visual studio 2013 keybinding poster
  • visual c# 2013 keybinding reference poster
  • visual studio 2013 default key bindings
  • visual studio 2012 keybinding poster
  • microsoft visual 2012 c# default key bindings
  • microsoft visual 2103 c# default key bindings

First use of Visual Studio 2010 : the installation

Yesterday I received a visual studio 2010 Ultimate edition from work.

I’ve already test the  express edition when it was in beta phase, but it’s not the same …

So, let’s install it !

I install it on a Fujitsu Siemens laptop with 4 GB Ram and a Intel Core 2 Duo processor (2,53 GHz) running  Windows 7 64 bit Ultimate edition.

image

 

Launch the auto run program

image

Loading screen

image

Click Next

image

Read and accept the license terms

image

Choose your installation mode : Full installation (takes more than 6 GB) or Custom installation

image

I choose Custom

image

Select the features you want :

image

(notice that “Microsoft SharePoint Developer Tools” are integrated)

I just don’t want Dotfuscator community to be installed, so I uncheck  it

I keep the rest because I want to test some features

image

Click Install

Installation running :

image

After less than 10 minutes, the installation asked me to restart my computer:

image

image

I click “Restart Now”

 

When restarting, a loading form is showing

image

Then the setup continue

image

After about 45 minutes, the setup is finished

image

You can choose to install the documentation, but I choose to click on the “Finish” button.

 

The installation windows appears :

image

I Click Exit

Visual Studio 2010 is now installed

 

The installation takes me about one hour, and no problem occurred.

Now I can launch the product

image

 

image

 

I choose my default environment settings (I used to choose Visual C# Development settings so I pick this one).

image

I Click on “Start Visual Studio”

First time loading form

image

 

Visual studio is up and running

image

 

Help and documentation are on the start page:

A What’s new section is available on the start page :

Some other links are available :

  • Creating application with Visual Studio
  • Extending Visual Studio
  • Community and Learning Resources

 

Some resources for Windows, Web, Cloud, Office,SharePoint and Data development are accessible too.

 

Next step : migration of a Visual studio 2008 solution !

Incoming search terms:

  • Choose Default Environment Settings
  • first developed Fujitsu Siemens laptops
  • first use of visual studio installing
  • ideal settings for visual studio 2010 on first use