Note that there are some explanatory texts on larger screens.

plurals
  1. POEntityType 'x' has no key defined. Define the key for this EntityType
    primarykey
    data
    text
    <p>I have this action which receives a parameter and i want to print out all the results</p> <pre><code>public ActionResult MusicaGenero(string genero) { //should return more than 30 rows var results = con.artista.Where(x=&gt;x.genero==genero); return View(results); } </code></pre> <p>MusicaGenero have this</p> <pre><code>@model IEnumerable&lt;MvcApplication1.Models.detallesMusica&gt; @{ ViewBag.Title = "MusicaGenero"; Layout = "~/Views/Shared/_Layout.cshtml"; } &lt;h2&gt;Musica del genero de: @ViewBag.genero&lt;/h2&gt; &lt;ul&gt; @foreach(var detallesMusica in Model) { &lt;li&gt;@detallesMusica.artista&lt;/li&gt; &lt;li&gt;@detallesMusica.nombre&lt;/li&gt; &lt;li&gt;@detallesMusica.publicado&lt;/li&gt; &lt;li&gt;@detallesMusica.costo&lt;/li&gt; } &lt;/ul&gt; </code></pre> <p>How can but it throws an exception</p> <pre><code>\tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'album' has no key defined. Define the key for this EntityType. \tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'genero' has no key defined. Define the key for this EntityType. \tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'artista' has no key defined. Define the key for this EntityType. \tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'albums' is based on type 'album' that has no keys defined. \tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'generos' is based on type 'genero' that has no keys defined. \tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'artista' is based on type 'artista' that has no keys defined. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.Entity.ModelConfiguration.ModelValidationException: One or more validation errors were detected during model generation: \tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'album' has no key defined. Define the key for this EntityType. \tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'genero' has no key defined. Define the key for this EntityType. \tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'artista' has no key defined. Define the key for this EntityType. \tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'albums' is based on type 'album' that has no keys defined. \tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'generos' is based on type 'genero' that has no keys defined. \tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'artista' is based on type 'artista' that has no keys defined. </code></pre> <p>what is the problem here? I added already a key but still giving me that error.</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.
 

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