0

I'm pretty new to Entity Framework, and I might be having a hard time "asking the right question" on google. So i'll try here.

First some facts:

  • I'm working on a project based on the Entity Framework 6.x.
  • I'm using the Model First approach.
  • The database is an SQL Server.

My challenge:

Every time my Unit Tests run, I'm dropping creating and seeding a test database using the DropCreateDatabaseAlways<TContext> implementation. The Data Source is an (localdb)\v11.0 instance.

I've gotten to a point where I would like to map an entity to a database view. I can find plenty of material on how easy it is to do the mapping, but what I'm looking for is a way for the view to be applied to my test database upon database creation/initialization?

I'm trying to keep a pure Model First approach. Can anyone help with information on how the views (and Stored Procedures) can be created, when creating the database?

user705703
  • 41
  • 6

1 Answers1

0

not sure this can be done.

I recently open an issue on codeplex for similar stuff but related to Code First.

The answer was: "edit generated code by hand".

In your case this should be done by inspiring yourself of this post about model first seed data. Instead of seeding, you should send DDL creating view through SQL(...) method as suggested in the answer of cited issue.

BTW: if you think, as I, that such a support should be a good idea, feel free to upvote code first support for view, and/or to create a model first support for view.

Community
  • 1
  • 1
tschmit007
  • 7,559
  • 2
  • 35
  • 43