I have 2 tables as shown here:
Table A
:
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[AName] [uniqueidentifier] NOT NULL
Table B
:
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[ANameID] [uniqueidentifier] UNIQUE NOT NULL
I want to create a one-to-many relationship between B
and A
where the ANameID
in the B
table can reference one or more rows in the A
table using the AName
column in the A
table. The A.AName
column is NOT the primary key.
There can be many rows in TABLE A with the same AName value, but only one row in TABLE B with the ANameID value.
How can I implement this either in SQL or in EF?
If you put a Unique Index on RoadId in table Roads then you can create a Foreign Key.
However, two thoughts:
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.