Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Plastic Snake
Mar 2, 2005
For Halloween or scaring people.
use entity framework

Adbot
ADBOT LOVES YOU

Plastic Snake
Mar 2, 2005
For Halloween or scaring people.
yeah i stay away from relationship modeling in code-first EF, its always turned into a massive pain in the rear end with not enough control for me.

what i do instead is just model my entities as standalone objects in the db, and use a repository pattern and sql queries to do what i want. so if you needed to add a Fart to a Butt, the API looks like ButtRepository.AddFart(Fart fart); which just does the needful with the database.

if you really want to do the code first thing tho, you can do this:

code:

public class Fart
{
  public int FartId { get; set; }

  [ForeignKey("FartOwner")]
  public int FartOwnerId { get; set; }
  public Butt FartOwner { get; set; }
}

Plastic Snake fucked around with this message at 17:48 on Sep 28, 2013

Plastic Snake
Mar 2, 2005
For Halloween or scaring people.
it is dumb, that's why I said not to do it that way. much better to use it as a statement mapper.

Plastic Snake
Mar 2, 2005
For Halloween or scaring people.
working on a little random terrain/map generator. implementing perlin noise is making my head hurt

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply