Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't add a controller in asp.net MVC3 EF code first
    text
    copied!<p>I have created a new project from template. I used windows phone cloud toolkit template which server side is a regular asp.net mvc3 project with EF 4.1 code first.</p> <p>My datacontext is called SqlDataContext and has the following constructor:</p> <pre><code>public SqlDataContext() : base(ConfigReader.GetConfigValue("SqlSampleDataContextConnectionString")) { } public DbSet&lt;SqlSampleData&gt; SqlSampleData { get; set; } </code></pre> <p>My connection string defined in web.config as:</p> <pre><code>&lt;connectionStrings&gt; &lt;add name="ApplicationServices" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=true;User Instance=true;AttachDBFilename=|DataDirectory|\WPCloudApp26.mdf;Initial Catalog=WPCloudApp26;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; </code></pre> <p>I have added a new model called <code>Report</code> and now i want to create new controller with the add controller wizard, using my new <code>Report</code> model and the <code>SqlDataContext</code>. when I try to create i get the following error:</p> <pre><code>Unable to retrieve metadata for 'WPCloudApp1.Web.Models.Report'. The 'SqlSampleDataContextConnectionString' setting is not available. Parameter name: key </code></pre> <p>And it fails to create the new controller.</p> <p>What am i doing wrong ? My background in this topic very scarce so please try to make it as simple as possible.</p> <p>My Report class:</p> <pre><code>namespace WPCloudApp26.Web.Models { using System; using System.ComponentModel.DataAnnotations; // Summary: // Sample Entity Framework 4.1 data class for SQL Azure. // Using EF 4.1 Code-First, the database structure will be created to mirror this class properties. // For more information, visit the ADO.NET Entity Framework website at http://msdn.microsoft.com/data/aa937723 public class Report { [Key] public int Id { get; set; } public string UserId { get; set; } public string Description { get; set; } public DateTime Date { get; set; } public bool IsPublic { get; set; } } } </code></pre> <p>Thanks.</p> <p>Edit: I have no problem running the application, only adding a new controller.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload