Basically, I have two tables. Principal table let's say "Foo" that has PK column ID of type int, and dependent table "Bar" that has PK column FooID of type int that is also a FK to ID of "Foo".
As I understood, the problem is that dependent type lacks [Foreign Key] attribute on the primary key property. Problem can be resolved on dependent type's side by either specifying [Foreign Key] attribute on PK or specifying [Required] attribute on the navigation property of PK.
I have tried to add [Required] but it didn't help much. Problem was resolved but models couldn't pass validation because of that. I don't want them to be validated because those properties can be null sometimes, at least when I use them to insert to DB. Turning off validation check on SaveChanges() also didn't help because I started to get other weird exceptions.
Now I want to try specifying [ForeignKey] attribute but can't figure out how to make it happen. I don't have experience with T4 (*.tt file). I don't know how to check property if it's a fk and don't know how to get its name. So please help me.