본문 바로가기

C#/Entity Framework

[EF] PluralizingTableNameConvention

PluralizingTableNameConvention


테이블 이름을 엔티티 이름의 복수화된 버전으로 만들어준다.
(Item -> Items, Player -> Players)

기본값은 적용이니, 수동으로 제거할 수 있다.


이 작업은 마이그레이션이 필요하다. 마이그레이션 없이 실행하면 다음과 같은 익셉션이 발생한다.

처리되지 않은 예외: System.InvalidOperationException: The model backing the 'MyDb' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).


이 작업에 대한 마이그레이션 스크립트는 아래와같이 생성된다.