|
Hi feanz,
I have too this problem when i remove the public property TeamId, eg. It´s an Issue that is good to solve.
So, above follow the example my domain structure:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Mvc3SampleDDLFor.Models
{
public class Player
{
public int PlayerId { get; set; }
public string Name { get; set; }
//public int TeamId { get; set; }
public virtual Team Team { get; set; } // This is new
}
}
...and:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace Mvc3SampleDDLFor.Models
{
public class Team
{
public int TeamId { get; set; }
[Required]
public string Name { get; set; }
public string City { get; set; }
public DateTime Founded { get; set; }
public virtual ICollection<Player> Players { get; set; } // This is new
}
}
ie i needn´t declare TeamId as Player´s Property, to Bind DropDown work; only with
public virtual Team Team {
get; set; }
|