MVC3: it is not possible to get metadata for my model class when I want to get model data from the controller

I am new to asp.net MVC3 platform. I follow the tutorial which is posted on asp.net website: http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part1-cs

But in the fifth step, which I need to access the data of my model class from the controller, I ran into some problems, I created a model class and a context class, but when I want to create a controller class using a forest template (a controller with read actions and views / entries using entity framework), this gives me an error, as shown below:

it is not possible to get metadata for the "full name of my model class". Failed to initialize configuration system

+15
asp.net-mvc asp.net-mvc-3 razor
Feb 20 2018-12-12T00:
source share
5 answers

Just change the provider type of the connection string to System.Data.SqlClient

+18
Sep 22 '12 at 16:39
source share

No mistakes. You just need to follow the chronological order to reflect the structure of the model and be transferred to the database and not have errors:

  • Create the controllers (do not include the connection strings in Web.config yet or you will get the specified error.)
  • Add a connection string to Web.config with what is written in the tutorial.
  • Finally, run the application.

NOTE. . Do not manually create a compact database, as Visual Studio will automatically create and display it for you along with the model structure when it starts and go to this controller in your browser. Just make sure you have the correct database path in Web.config . Hope this helps! Regards.

+12
Jan 16 '13 at 9:18
source share

Try this one ...

 <add name="MovieDBContext" connectionString="data source=.\SQLEXPRESS;&#xD;&#xA; Integrated Security=SSPI;&#xD;&#xA; AttachDBFilename=|DataDirectory|\MVCtest.sdf;&#xD;&#xA; User Instance=true" providerName="System.Data.SqlClient" /> 
+5
May 9 '12 at 5:15
source share

I changed the provider name in System.Data.SqlClient, as suggested in another android. This allowed me to create a controller in the step of adding a controller. But the application will not display the movie resource at all when I launched it. Then I changed it back to System.Data.SqlServerCe.4.0, as in the tutorial, and it worked.

After reading other discussions on the Internet, I found another method.

If you do not add a connection string until you create a controller class, it will work as well. This seems like a mistake.

+5
Oct. 16
source share

Make sure you add the connection string to the correct web.config file, because there are 2 (one at the solution level and the other at the presentation level). You want to add it at the presentation level. Your crud material will only be created perfectly after you fix the connection string, then create a controller. Thanks Maurice Maglalan

0
Sep 16 '13 at 1:15
source share



All Articles