Buonasera a tutti, sono un niubbo con ASP.Net!
ho questo problema:
ho creato un nuovo modello con il seguente codice:
e la seguente connection string:codice:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.Entity; using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace MvcApplication1.Models { public class Voti { [Key] public int id { get; set; } } public class FantacalcioDBContext : DbContext { public DbSet<FantacalcioDBContext> Voti_Giornate { get; set; } }
codice:<add name="FantacalcioDBContext" providerName="System.Data.Sqlclient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Fantacalcio;Integrated Security=True;MultipleActiveResultSets=True" />
Quando vado a creare un nuovo controller con Modello MVC entity framework mi da questo errore.
Impossibile recuperare i metadati per xxxxxxx.
One or more validation errors were detected during model generation:
- system.data.entity.edmentity type: Entity type FantacalcioDBContext has no key defined. Define key for this entity type.
Lato DB ho definito tutte le chiavi primarie sulle tabelle, e non riesco a capire a quale key faccia riferimento.
Grazie ragazzi!

Rispondi quotando