I faced with the next problem. I have a data warehouse with model
public class GameResult
{
public int GameResultId { get; set; }
public virtual Competition Competition { get; set; }
public virtual CustomDate DateGame { get; set; }
public virtual Contender ContenderFirst { get; set; }
public virtual Contender ContenderSecond { get; set; }
public virtual Location Location { get; set; }
}
public class Competition
{
[Key]
public int CompetitionId { get; set; }
public string Name { get; set; }
//Lazy loading
public virtual KindSport KindSport { get; set; }
}
Something like that
I generate some data for fact table GameResult
gameResult.Location = location;
gameResult.Competition = competition;
gameResult.ContenderFirst = firstContender;
gameResult.ContenderSecond = secondContender;
public void saveGameResult(GameResult gameResult)
{
using (var db = new GameContext())
{
db.GameResults.Add(gameResult);
db.SaveChanges();
}
}
But when I try to save data get that I don't save enity just in fact table they getting cascade saved also in child tables as Location, Contender
.
How I can solve my problem?