0

Suppose i have 5 tables and 2 views. I have created 7 EF objects. But when i initialise database, EF creates 2 tables for the 2 views. I need to manually delete those tables and create my views by hand. Is there a way to avoid this 2 tables generation ? (i am working on mysql)

testpresta
  • 429
  • 5
  • 15
  • Do you add the tables to the database context? – Ron Beyer Dec 07 '15 at 21:38
  • http://stackoverflow.com/questions/7461265/how-to-use-views-in-code-first-entity-framework – DavidG Dec 07 '15 at 21:43
  • Yes i have declared DbSet for the views in DbContext class. But if i remove the 2 DbSet, i cannot read views result from my C# Code – testpresta Dec 07 '15 at 21:47
  • You need to add more than just the `DbSet` for the views, you need to have the other tables too, unless there are navigation properties in the views to the other tables, then you may have your navigation properties set up incorrectly. – Ron Beyer Dec 07 '15 at 22:03

0 Answers0