Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MVC5 DB FIRST

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

As master has been working on the development of codefirst, there is a new requirement recently, that is, I need someone else's database, and then I will develop it. Now there is a problem. The arrangement is as follows

At present, there is a ready-made engineering code for our previous codefirst. I remember Master said that the way to generate model from the database is:

In the specified folder, right-click to add-- > New item-- >

Here first select the data, and then ADO.NET, in the name below, enter the name you want to generate, but this name is best from the name of a project, because you can select all the tables, not a separate table name, so what I do here is OA, I named OA.

Look at the results.

These tables are generated, and the code results

A database connection is also generated.

The OA.tt here is the generated T4 template, which contains the model corresponding to the database.

Here is a problem description, the generated OA.Context.cs file, this is the DBContexts.cs in our previous codefirst, which is initialized in the database context factory.

What is marked here is related, so the name here has to correspond to the one in OA.Context.cs.

The purpose of this explanation is that I didn't know the database context at all before, the original database context factory is still the original DBContexts, and I don't understand that this needs to be changed to a new one, so the startup has been reporting an error, and now it's okay.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report