Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>nobody can see, why your code is not working, from the amount of code you have posted.</p> <p>however, make sure following :</p> <ol> <li>the class of the instance <code>contexto</code> inherits <code>DbContext</code> or any child class inheriting <code>DbContext</code>.</li> <li><p>make sure, in case, you have not generated the database, through the code,rather mapped an existing database, to a codefirst frontend, that <code>DbSet&lt;Idioma&gt; Idiomas</code> is mapped to proper table. ie. </p> <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity&lt;Idioma&gt;().ToTable("IdiomaTableNameInDatabase"); } </code></pre></li> <li>make sure, your connectionString name, that you passed in the DbContext base constructor is present in the web.config, and if you have not passed anything, make sure a connectionString with the name of your DbContext inheriting class is there.</li> </ol> <p>If all these are correct, there is absolutely no reason, why <code>contexto.Idiomas.ToList()</code> won't return anything.</p> <p>and also, say, your context class is MyContext, then it should be like this:</p> <pre><code>public class MyContext:DbContext { public MyContext:base("ConnectionStringName") { } //--dbSet properties public DbSet&lt;Idioma&gt; Idiomas{get;set;} //other overridden methods } </code></pre> <p>which you use, on your upper layers like this:</p> <pre><code>public List&lt;Idioma&gt; GetAllIdiomas() { MyContext contexto = new MyContext(); return contexto.Idiomas.ToList(); } </code></pre>
 

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