0

I'm learning EF code first from database using this MSDN tutorial. The generated model partial class names always match the database object names. Instead I'd like to assign an alias to the generated database model objects. How should I go about doing this?

Specifically the database view named vwDS_ProductCategories generates a public partial class vwDS_ProductCategories which I'd like to alias as ProductCategories. The reason for doing this is that non-programmers will see (and make use of) the types exposed by my generated dll. I'd like the type names to make sense to these users.

DeveloperDan
  • 4,626
  • 9
  • 40
  • 65
  • I have answered based on Code first, do you meant Database first? – Juan Jul 20 '15 at 15:31
  • Your answer worked perfectly. I'm transitioning from database first to code first. By trying it out I learned that the Table attribute works for my database view as well. Thanks! – DeveloperDan Jul 20 '15 at 15:38

1 Answers1

2

Try this:

[Table("vwDS_ProductCategories")]
public partial class ProductCategories
{
}
Juan
  • 3,675
  • 20
  • 34