AliRıza Adıyahşi
AliRıza Adıyahşi

Reputation: 15866

ASP.NET MVC relationship codefirst and existing database table?

I m new about this topic (code first development). I want to do relationship between asp.net default User table and my class (one-to-one).

  1. Is this possible.
  2. if this is possible.How I can do it.Should I write User class, too? or any way.

Could you give me a starting point? My class is like below.

public class Customer
{
    [Key]
    public int customer_id { get; set; }
    public string customer_name{ get; set; }
    public string user_id

    public virtual User User{ get; set; }
}

I hope, I have explained :)

Thanks.

Upvotes: 1

Views: 948

Answers (1)

Igor Konopko
Igor Konopko

Reputation: 764

If I undestand correctly - yes, you shoul write all the classes what you want to use in youre code, even if thay exist in the database. Here some tutorial, maybe it can help's you http://codefirst.codeplex.com/

Upvotes: 1

Related Questions