c# - Entity Framework "Database First" not generating Foreign keys -
i used entity framework reverse engineering seems miss foreign key relations. here database sql code , generated classes:
create table [dbo].[rapportanomalie] ( [code_rapport] int identity (1, 1) not null, [date_rapport] datetime not null, [etat] varchar (50) not null, [code_agence] int not null, primary key clustered ([code_rapport] asc), constraint [fk_rapportanomalie_totable] foreign key ([code_agence]) references [dbo].[agence] ([code_agence]) create table agence ( [code_agence] int not null primary key, [intitule_agence] varchar(100) not null, [adresse_agence] varchar(100) not null ) agence.cs:
[table("agence")] public partial class agence { [key] [databasegenerated(databasegeneratedoption.none)] public int code_agence { get; set; } [required] [stringlength(100)] public string intitule_agence { get; set; } [required] [stringlength(100)] public string adresse_agence { get; set; } } } and rapport.cs:
[table("rapportanomalie")] public partial class rapportanomalie { [key] public int code_rapport { get; set; } public datetime date_rapport { get; set; } [required] [stringlength(50)] public string etat { get; set; } public int code_agence { get; set; } } } what problem there?
probably duplicate question following linkthe question posed on stack on flow
and here related answer of above link guess of value youef reveres engineering
good luck
Comments
Post a Comment