Table A:
public A()
{
Bs = new List<B>();
}
public ICollection<B> Bs {get; set;}
Table B:
public B()
{
a = new A();
}
public A a {get; set;}
If I have a foreign key of A's primary key int Id column to B's int column, it's working fine.
But I want a foreign key of A's unique key varchar
column to B's varchar
column, and when I run query it throws an error of converting varchar to int?
In short: can anyone give me idea to deal with non primary key as foreign key to other table in Entity Framework code-first approach?
As of now, Entity Framework does not support alternate keys. They have just started "introducing" them in version 7 - Channel 9 video .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.