none
Entity Frame Work : Removing "s" from the table name which ends with "s" RRS feed

  • Question

  • Hi,

    I am facing a problem with entityframe work for the table names ending with "s"  

    For Example. 

    If I have a table  Status  , then entity framework is removing "s" from the table name   and its showing Statu in the code.

    How can I resolve this issue.

    Thursday, December 29, 2011 9:08 PM

Answers

  • Hi priya2silverlight;

    That will all depend on how you are coding. If you are using OR/M designer then in the designer click the name of the table when it turns into an editable textbox and modify the spelling as you want it to be in your code, done.

    If you are using Entity Framework 4.1 or newer you can add a Table Data Annotation to the class definition as follows :

    // namespace for Data Annotation
    using System.ComponentModel.DataAnnotations;

    [Table("Status")]
    public class Status

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, December 30, 2011 2:52 AM
  • Hi,

    you're probably using EF 4.1.

    you can do this:

    Override OnModelCreating method of your context class and write this -

    modelBuilder.Entity<Status>().ToTable("Statuses");

    Regards,

     

    Giorgi

     

     


    Clarity VS Precision
    Friday, December 30, 2011 3:39 PM

All replies

  • Hi priya2silverlight;

    That will all depend on how you are coding. If you are using OR/M designer then in the designer click the name of the table when it turns into an editable textbox and modify the spelling as you want it to be in your code, done.

    If you are using Entity Framework 4.1 or newer you can add a Table Data Annotation to the class definition as follows :

    // namespace for Data Annotation
    using System.ComponentModel.DataAnnotations;

    [Table("Status")]
    public class Status

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, December 30, 2011 2:52 AM
  • Hi,

    you're probably using EF 4.1.

    you can do this:

    Override OnModelCreating method of your context class and write this -

    modelBuilder.Entity<Status>().ToTable("Statuses");

    Regards,

     

    Giorgi

     

     


    Clarity VS Precision
    Friday, December 30, 2011 3:39 PM