Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to configure multiple Foreignkey referancing to same table from main table using EF Code First Fluient API
    primarykey
    data
    text
    <p>I have to design a web application using existing database of desktop application. As per existing database i have below class</p> <pre><code>public class Company { #region Primitive Properties public virtual int CompanyID { get; set; } public virtual string CompanyName { get; set; } public virtual bool IsCustomer { get; set; } public virtual string CustomerCode { get; set; } public virtual bool IsPotentialCustomer { get; set; } public virtual bool IsSupplier { get; set; } public virtual string SupplierCode { get; set; } public virtual bool IsPotentialSupplier { get; set; } public CompanyCategoryCodes CustomerCategoryCode { get; set; } public CompanyCategoryCodes SupplierCategoryCode { get; set; } public CountryCode CountryCode { get; set; } } public class CompanyCategoryCodes { public virtual int CategoryID { get; set; } public virtual string CategoryCodes { get; set; } public virtual bool PotentialCustomer { get; set; } public virtual bool PotentialSupplier { get; set; } public virtual System.DateTime LastModifiedDate { get; set; } public virtual bool Manufacturer { get; set; } } public class CountryCode { public virtual int CountryCodeID { get; set; } public virtual string Code { get; set; } public virtual string Description { get; set; } public virtual bool DefaultCode { get; set; } public virtual bool EECVATApplies { get; set; } public virtual System.DateTime LastModifiedDate { get; set; } public virtual bool FixedAddressFormat { get; set; } } </code></pre> <p>EF Code first default framework is creating Foreignkey with name "CustomerCategoryCode_CategoryID" , "SupplierCategoryCode_CategoryID", "CountryCode_CountryCodeID". I want this Foreignkey name to be consistance with my old database tables e.g. "CustomerCategoryCodeID", "SupplierCategoryCodeID", "CountryCodeID". How can i do it using EF Code First Fluient API. I try to do it using Fluient API Mapping but i got error for "SupplierCategoryCode_CategoryCodeID" as "CustomerCategoryCode_CategoryID" is also locating to same table "CompanyCategoryCode". Also if is there any option available using Data Annotation then also let me know how to achieve this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload