2

I have a database with a lot of tables, and table X has many foreign keys to table Y. When I use Entity Framework Code First to generate C# model corresponding to may database the class X has a lot of properties of type Y called Y, Y1, ... Yn. For example:

public virtual Author Author { get; set; }
public virtual Author Author1 { get; set; }
public virtual Author Author2 { get; set; }

And I want to have something like:

public virtual Author Writer { get; set; }
public virtual Author Supervisor { get; set; }
public virtual Author Reviewer { get; set; }

Coresponding to mai SQL table columns:

[WriterId] [int] NOT NULL,
[SupervisorId] [int] NOT NULL,
[ReviewerId] [int] NOT NULL,

I know that I can add partial classes to add extra properties like in below example:

public virtual Author AuthorWriter 
{
    get
    {
        return this.Author1;
    }
    set
    {
        this.Author1 = value;
    } 
}

but I would have to much code to write. So my question is if is there a way in Visual Studio 2013 to configure how virtual properties names are generated by Entity Framework?

I mention that I do not want to change the generation of C# model way because the database is larger and I do not have access to modify its structure, moreover if the database is changed I should regenerate my C# model.

Thanks in advance

roroinpho21
  • 732
  • 1
  • 11
  • 27
  • Possible duplicate of [Improve navigation property names when reverse engineering a database](http://stackoverflow.com/questions/12937193/improve-navigation-property-names-when-reverse-engineering-a-database) – Steve Greene Dec 14 '16 at 21:32

0 Answers0