EF6 db first pluralize/singularize for table names that contain underscores

c# entity-framework-6 visual-studio-2015

Question

I am trying to create a new Entity Data Model (database first) with entity framework 6 using the wizard provided in Visual Studio 2015 Community edition. All my table names are pluralized (ex. mn_Bills). I chose the "Pluralize or singularize generated object names" but this does not singularizes the object names (i.e. the generated class for table mn_Bills is mn_Bills in a mn_Bills.cs file).

I have modified the "Name" and "Entity Set Name" in the Model Browser which resolved only partly the problem. The classes generated are singular, which is good, but the foreign key associations for N to 1 associations are pluralized:

public partial class mn_Bill
{
    ...
    public virtual mn_Clearing mn_Clearings { get; set; }
}

Do you know if there is any workaround for this problem (besides changing the table names)?

1
2
5/4/2016 10:44:38 AM

Popular Answer

I met a similar problem with underscore table names and it seems that the PluralizationService doesn't support underscores.

The answer, it seems, is to override the default service with some of your own code.

I've not done this for a database first edmx solution, because I'm using an alternative code generation engine - but this may be possible to override in the code generation step.

See this answer here:

Entity Framework EDMX - Entity Pluralization Fix

https://blogs.msdn.microsoft.com/efdesign/2008/12/01/pluralization/

0
6/21/2017 3:03:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow