Note that there are some explanatory texts on larger screens.

plurals
  1. POEF6, Code-First, enable-migrations, "Unable to load the specified metadata resource"
    primarykey
    data
    text
    <p>I have created a C# class library with 3 entity classes and a DbContext for code-first generation of database. All has gone well with version 1. I have created a separate test library and the class library with the DbContext class has been behaving as expected.</p> <p>Now, I wanted to make one of the fields mandatory and following the code-first conventions, I have added a [Required] attribute to the property in the entity class. The next step was to enable migrations.</p> <p>I went to the Package Manager Console, entered "enable-migrations" and ... bang ... "<strong>Unable to load the specified metadata resource</strong>".</p> <p>For reference, my DbContext class includes:</p> <pre><code>public OrganisationsContext() : base("Leegz_Entities_Organisations") { this.Configuration.LazyLoadingEnabled = false; this.Configuration.ProxyCreationEnabled = false; } public DbSet&lt;Organisation&gt; Organisations { get; set; } public DbSet&lt;Member&gt; Members { get; set; } public DbSet&lt;LeegzUser&gt; LeegzUsers { get; set; } </code></pre> <p>and my app.config contains:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt; &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt; &lt;/configSections&gt; &lt;entityFramework&gt; &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt; &lt;parameters&gt; &lt;parameter value="v11.0" /&gt; &lt;/parameters&gt; &lt;/defaultConnectionFactory&gt; &lt;providers&gt; &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt; &lt;/providers&gt; &lt;/entityFramework&gt; &lt;connectionStrings&gt; &lt;add name="Leegz_Entities_Organisations" connectionString="data source=NEIL-INSPIRON\NEILDEV;initial catalog=TheLeegz;integrated security=True" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; &lt;appSettings&gt; &lt;add key="Leegz.Entities.Organisations.DbSecuritySchema" value="Leegz.Entities.Organisations"/&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <p>I've seen a number of threads on this subject, but they all seem to be talking about errors in reference elements of the EDMX model file. However, as I've used code-first, I don't have a model (maybe I'm missing a step here), so the advice that I've seen in relation to the EDMX information in the connection string does not seem to apply to me.</p> <p>Any ideas, please?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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