EF "Model First": create an object in edmx and db-table from a class?

This question is part of my next one, which I already asked about 2.5 years ago: Entity Framework (.NET) Circular modeling with the first model?

I wanted to ask if at the same time there is the following (and from which version of EF up):

We are currently using EF 5.0 with the “Model First” approach (VS 2012). After the first problems, we were able to configure two T4 templates for generating the DbContext and POCOs classes, so that if we need to map a new (or existing) database table, we can do this by right-clicking in the designer VS EF> "update model from the database ... "everything works well (our database has many tables and my EF model does not display all of them).

Now we have some other (POCO) classes that are not yet mapped to objects (in the / edmx designer) and we don’t have any tables in the database for them. Using the "model one" approach (we used so far), is it possible to generate both table schemas (we also need the generated SQL) in the database and objects in the / edmx constructor (metadata)? (I know that the name “model first” can say this, but perhaps the same is used as a reference for “code first” in the following section: should “edmx based” be better?)

I know the "first code" (or better: "code-based", http://blogs.msdn.com/b/adonet/archive/2014/10/21/ef7-what-does-code-first-only- really-mean.aspx ) can do such things, but as far as I know, mappings are then only created temporarily in virtual memory, and not in edmx (which we need).

One of my ideas is to create an additional mini-project using code first, generate db tables, and from them update my edmx in our project mentioned above; or is it possible to somehow write edmx out of a temporary model generated first by the code?

It would be great if someone knew a more elegant solution,
thanks in advance.

Useful articles by Arthur Vickers:
http://blog.oneunicorn.com/2012/02/26/dont-use-code-first-by-mistake/
http://blogs.msdn.com/b/adonet/archive/2011/03/07/when-is-code-first-not-code-first.aspx

The following SO streams are also good matches, but somewhat old (EF 4):
Using the EF4 Migration Tool Using a Model-Based Approach
Entity Framework 4.1 Code First EDMX Issue

+1
source share

Source: https://habr.com/ru/post/1270272/


All Articles