EF6 CodeFirst Dsde Database Update Model C #

0

I have a solution of n-layers, inside which I have separate the DAL of the entities.

For this, I am using the model called Code First from Database , which although it works quite well, because it allows me to separate the entities in a different project.

It has the disadvantage that when I update the database (the DBA), I see myself in the obligation to rebuild the DAL, and re-separate the entities generated in the other project.

  

Is there a way to automate this process?

I've been seeing Migrations , but that only works when I update the model (I'm not sure if this method works, if the model is in another project).

Greetings

    
asked by Luis Gabriel Fabres 14.03.2017 в 17:01
source

1 answer

1

CodeFirst from database is not thought to be updating the model from the DDBB, the idea is to make a first import and then go modifying the classes and making migrations.

If the source of the model is the database I would recommend that you change your focus and instead of using CodeFirst from the database use the EF Designer model (I do not remember the exact name, it is the visual model).

update - explanation of how to make entities create in any project:

With the Database First approach you can specify where you want entities to be created by modifying the T4 template used by the EDMX file.

The easiest way to do it is to take the * .Context.t4 to the solution where you want to store the entities, then edit the T4 and in the section

const string inputFile = @"Model1.edmx";

You specify the route to EDMX.

ModelFirst Tutorial

    
answered by 14.03.2017 в 17:35