MVC “Add Controller” is “Unable to Retrieve Metadata…Config System Failed to Initialize”

前端 未结 11 1006
天涯浪人
天涯浪人 2021-01-04 18:31

From scratch, I made a new solution with two projects: one was MVC 3 and the other a supporting EF 4.2 project. The whole thing builds successfully. From the MVC project I

相关标签:
11条回答
  • 2021-01-04 18:52

    Just copy the connection string information from your EF model project App.Config into your and watch that you do not repeat any sections (entityFramework section for example)

    0 讨论(0)
  • 2021-01-04 18:53

    I added this to my Global.Asax file so that a) the database was started immediately and b) the table definition was added. allowing the Controller to find the table definition:

     System.Data.Entity.Database.SetInitializer<ProjectName.DAL.DBConnectContextName>(new CreateDatabaseIfNotExists<ProjectName.DAL.DBConnectContextName>());
    
    0 讨论(0)
  • 2021-01-04 18:55

    First of all you should check your connection string must be in your Web.Config file in the ROOT! of your project after that check if there is another connection string or not if there is another connection string replace it with your connection string.... This solved my problem which was same as your's....

    0 讨论(0)
  • 2021-01-04 18:56

    Try this:

    <add name="Monsters2Entities" 
    
        connectionString="
          metadata=res://*/Monsters.csdl|
                   res://*/Monsters.ssdl|
                   res://*/Monsters.msl;
          provider=System.Data.SqlClient;
          provider connection string='
            data source=.;
            initial catalog=Monsters2;
            integrated security=True;
            pooling=False;
            multipleactiveresultsets=True;
            App=EntityFramework
          '" 
          providerName="System.Data.EntityClient" 
    />
    

    I have replaced &quot; with '

    0 讨论(0)
  • 2021-01-04 18:59

    first need to install package entity framework

    go to tool> Libray package manager> pakage manager console > :install entity framework

    0 讨论(0)
提交回复
热议问题