我将按照以下步骤创建一个新的ASP.NET项目:
1. Create New Project
a. Under Visual C#, select Web
b. Click on ASP.NET Web Application
c. Give project a name and location to be saved
2. On the New ASP.NET Project window, select MVC and make sure MVC is checked under “Add folders and core references for”. Also, check the box “Add unit tests”
3. In Solution Explorer, right-click on the Models folder, and then add a new class. This will be your first model.
4. In the class file that you just added, give it any properties that the object may need. Remember, this model will represent a table in your database and the properties represent the columns of that table in the database.
5. In the Models folder, click on IdentityModels.cs. Under class ApplicationDbContext, add a property of type DbSet<> i.e. DbSet<Person> Person
6. For migrations, locate the Package Manager Console. Then type in the following commands:
a. Enable-Migrations
b. Add-Migration MigrationName
c. Update-Database
7. To add a Controller without scaffolding:
a. right-click on the Controllers folder and click Add Controller. Then select “MVC 5 Controller - Empty”
b. Give the Controller a name
c. Notice under the Views folder there is an empty subfolder with the name you just gave your Controller
d. Right-click on the subfolder and click Add View.
e. Give the View a name i.e. Create. Then, select a View template from the drop-down list i.e. Create
f. Select the drop-down list for Model class. Select the Model you are creating a Controller for. Also, select the data context class you want to use. It will likely be ApplicationDbContext.
8. To add a Controller with scaffolding:
a. Right-click on the Controllers folder and click Add Controller. Then select “MVC 5 Controller with views, using Entity Framework”. This is called scaffolding.
b. When the Add Controller window pops up, select the drop-down list for Model class. Select the Model you are creating a Controller for. Also, select the data context class you want to use. It will likely be ApplicationDbContext. Leave all three boxes checked under the Views section. Then click “Add”.
9. To check out your Connection String, double-click on the Web.config file in the Solution Explorer在步骤5中,没有IdentityModels文件、AccountViewModels文件或ManageViewModels文件,就像通常的那样。我可能遗漏了什么步骤?
发布于 2018-07-30 08:18:53
在步骤2中,选择MVC后,在右窗格中,如果显示“无身份验证”,请单击“更改身份验证”,然后选择一个,从单独身份验证或windows身份验证开始。一旦你的项目创建完成,你就可以看到IdentityModel,AccountViewModel等。
https://stackoverflow.com/questions/51585470
复制相似问题