I am very new to code first. I have tried reading as much as I can but I have not found an answer to my question. When using object composition and code first how do you create a composite key. for example
public class Foo
{
public FooID {get; set;}
public FooName {get; set;}
}
public class Bar
{
public virutal Foo {get; set;}
public BarID {get; set;}
public BarName {get; set;}
}
How can I make sure in the DB schema that FooID and BarID are composite keys?
Also should I even do the virtual Foo? *or should create bar like this?* If I use the below bar implementation is there a way of being able to use statements like this bar.foo.name
(i doubt it but maybe EF does some cool magic to let this happen)?
Public Class Bar
{
public FooID {get; set;}
public BarID {get; set;}
public BarName {get; set;}
}
IF possible I would like to be able to do all that through data annotations. Thank you very much