[英]Why I can't use my classes from Models folder in Global.asax.cs?
I'm trying to do following project for learning purposes: https://docs.microsoft.com/ru-ru/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/create_the_data_access_layer 我正在尝试做以下项目以供学习: https : //docs.microsoft.com/ru-ru/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-表格/ create_the_data_access_layer
But I got stuck on the step "Updating the Global.asax file" - VS doesn't allow me to import WingtipToys.Models namespace to Global.asax.cs file. 但是我陷入了“更新Global.asax文件”这一步骤-VS不允许我将WingtipToys.Models命名空间导入Global.asax.cs文件。
Here's the project structure, Globa.asax.cs and 'using' error 这是项目结构Globa.asax.cs和“使用”错误
Everything is done according to Microsoft's tutorial above. 一切都根据上面的Microsoft教程完成。 Why can't I to import my models to global.asax.cs file?
为什么不能将我的模型导入global.asax.cs文件?
My ProductDatabaseInitializer class: 我的ProductDatabaseInitializer类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
namespace WingtipToys.Models
{
public class ProductDatabaseInitializer : DropCreateDatabaseIfModelChanges<ProductContext>
{
protected override void Seed(ProductContext context)
{
GetCategories().ForEach(c => context.Categories.Add(c));
GetProducts().ForEach(p => context.Products.Add(p));
}....
What did really help is a re-creation of all classes in Models directory (delete all old classes and create new ones with same code) - then I started to see my classes from Global.asax.cs file. 真正有帮助的是在Models目录中重新创建所有类(删除所有旧类并使用相同的代码创建新类)-然后,我开始从Global.asax.cs文件中查看我的类。
Maybe it could help someone. 也许可以帮助某人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.