ho questo due entityesEntity Framework Nome colonna non valido, EF aggiunge numer 1 di chiave primaria
public partial class Suscriptores
{
public Suscriptores()
{
this.Publicacion = new HashSet<Publicacion>();
}
[Key]
public int IdSuscriptor { get; set; }
public string LogoSuscriptor { get; set; }
public string Identificacion { get; set; }
public string Nombre { get; set; }
public string Direccion { get; set; }
public string Telefono { get; set; }
public string Email { get; set; }
public string Fax { get; set; }
public string Home { get; set; }
public virtual ICollection<Publicacion> Publicacion { get; set; }
}
public partial class Publicacion
{
public Publicacion()
{
this.Edictos = new HashSet<Edictos>();
}
[Key]
public decimal IdPublicacion { get; set; }
public System.DateTime FechaPublicacion { get; set; }
public string IdUsuario { get; set; }
public System.DateTime FechaPublicacionHasta { get; set; }
public System.DateTime FechaArchivoHasta { get; set; }
public int IdSuscriptor { get; set; }
public decimal IdTipoPublicacion { get; set; }
[ForeignKey("IdSuscriptor")]
public virtual Suscriptores Suscriptores { get; set; }
}
quando si tenta di eseguire questa query:
public ActionResult DetailsVSTO(string Identificacion)
{
var SusQ = from s in db.Suscriptores
where s.Identificacion == Identificacion
select s;
return Json(SusQ.First(), JsonRequestBehavior.AllowGet);
}
E gettare questo messaggio:
System.Data.SqlClient.SqlException: nome colonna non valido "Suscriptores_IdSuscriptor1"
Cercando di lve questo problema ho aggiungere questa fluente in DbContext
modelBuilder.Entity<Suscriptores>()
.HasMany(x => x.Publicacion)
.WithRequired(x => x.Suscriptores)
.Map(a => a.MapKey("IdSuscriptor"));
Ma il problema persiste. Come posso fare per risolvere questo.
Solo per curiosità, non dovrebbe essere questo un'associazione molti-pressi di molte? Non vorrei pubblicare qualcosa sapendo che posso ottenere solo un abbonato :) –
riguardo al 3 ° oggi Gert. Mi piacciono i tuoi post :-) –
Tks Gert per il tuo "commento", in realtà sono più nuovo con EF, solo un po 'di esperienza con esso.Ci sono molte "Pubblicazioni" per ciascuno "Suscriptores" e uno "Suscriptores" per ciascuna "Publications". È questo che voglio modellare. –