简体   繁体   中英

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

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.

Here's the project structure, Globa.asax.cs and 'using' error

Everything is done according to Microsoft's tutorial above. Why can't I to import my models to global.asax.cs file?

My ProductDatabaseInitializer class:

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.

Maybe it could help someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM