I’m developing ASP.NET in C# after performing aspnet_regsql on my database. I want to track Game objects and map them to users… if possible I’d like a user have a list of Games, but obviously I can’t put that in the current Membership implementation unless I write my own which I’m trying to avoid.
public List<Game> Games { get; set; }
In MVC however, how do I actually map this in another model (which would be using the same database, would just be another table within that database).
public class Games
{
[key]
public int GameId
Properties/Details about the game here....
//Foreign key to map to the specific user this Game belongs to
[Required]
public int UserId
}
Would this actually work? Does MVC in the background make sure that UserId is aspnet_User.UserId? I’d hate to create a extension of the MembershipProvider interface, but if the above doesn’t work I suppose I might have to!
Also, I’m not interested in leveraging profiles; as you can see, the data I’m trying to map to will be central to this application. Trying to parse through profile data is practically impossible when it also needs to map to other objects!
If you need to join the
Gamewithaspnet_User, then your setup will not work. For that you would have to mapaspnet_Useras an entity.On the other hand if you only need to retrieve the Games for a particular user then your model will work. Make sure you manually create a FK to keep the data integrity.
Edit
You can map the
aspnet_Usertable as an entity as follows