I build my RESTful webservice and after recreating model (replacing enums with strings) and database I have NULLs where there should be Guids of another rows in tables.
this is what I see in SQL Explorer in VS
MIGRATION METHODS:
public override void Up()
{
CreateTable(
"dbo.Artists",
c => new
{
Id = c.Guid(nullable: false),
FirstLastName = c.String(),
})
.PrimaryKey(t => t.Id);
CreateTable(
"dbo.Pictures",
c => new
{
Id = c.Guid(nullable: false),
Title = c.String(),
Path = c.String(),
})
.PrimaryKey(t => t.Id);
CreateTable(
"dbo.PieceOfArts",
c => new
{
Id = c.Guid(nullable: false),
Title = c.String(),
Description = c.String(),
DateOfCreation = c.Int(nullable: false),
Period = c.String(),
Techinque = c.String(),
Artist_Id = c.Guid(),
Picture_Id = c.Guid(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Artists", t => t.Artist_Id)
.ForeignKey("dbo.Pictures", t => t.Picture_Id)
.Index(t => t.Artist_Id)
.Index(t => t.Picture_Id);
}
public override void Down()
{
DropForeignKey("dbo.PieceOfArts", "Picture_Id", "dbo.Pictures");
DropForeignKey("dbo.PieceOfArts", "Artist_Id", "dbo.Artists");
DropIndex("dbo.PieceOfArts", new[] { "Picture_Id" });
DropIndex("dbo.PieceOfArts", new[] { "Artist_Id" });
DropTable("dbo.PieceOfArts");
DropTable("dbo.Pictures");
DropTable("dbo.Artists");
}
}
SAMPLE SEED OF THIS COMPLEXED CLASS (PieceOfArt) :
context.PieceOfArts.AddOrUpdate(x => x.Title,
new PieceOfArt()
{
Id = Guid.NewGuid(),
Title = "Syrenka warszawska",
Techinque = "Fresk",
Artist = context.Artists.FirstOrDefault(x => x.FirstLastName.Contains("Picasso")),
Description = "123",
Period = "Pierwsza awangarda",
Picture = context.Pictures.FirstOrDefault(x => x.Title == "Syrenka warszawska"),
DateOfCreation = 1946,
},