If I look at an existing project, how can I determine if this is the first EF code, or the first, or the first?

I am looking at an existing ASP.NET MVC (5.2.3) EF (6.1.3) project.

The project uses an ASP.NET identifier, and I looked at 2 connection strings in web.config, one for ASP.NET Identity and one for EF. Both points to the same database, I successfully changed them to call "mydb" I also reviewed the mydbModel.edmx project.

When I run the project, mydb is automatically created using the ASP.NET identity tables in it (as expected), however the other tables (for the objects defined in mydbModel.edmx) are not. There is no error message, except that the application does not find the table.

Further, I also found the following lines, so I believe this is not the first code:

public partial class MyDbEntities : DbContext { public MyDbEntities() : base("name=MyDbEntities") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { throw new UnintentionalCodeFirstException(); } 

Although I have been working with EF since its inception (mainly DB First), unfortunately, I am not sure about the other main methods and their variants.

What else should I check to make sure that the project concept is used, and how can I create the tables defined in the model?

+5
source share
1 answer

The code you posted definitely looks like a DB, because we will use DbModelBuilder to configure objects in OnModelCreating in Code First. Also, Code does not have any edmx file at first (we do not have it in our project).

+1
source

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


All Articles