SqlException (0x80131904): Invalid object name 'dbo.Categories'

后端 未结 5 583
我寻月下人不归
我寻月下人不归 2020-12-03 07:47

I am getting the exception above when I run an application. The application is using asp.net mvc 3 / C#. I made an mdf file and added it under App_Data folder in Visual Web

5条回答
  •  天涯浪人
    2020-12-03 08:26

    Try using model builder class.It is the way to configure or explicitly define the mapping between table and model class.

    In your entity/context class try adding this code

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
           base.OnModelCreating(modelBuilder);
           modelBuilder.Entity().ToTable("Category");
        }
    

    Its a method.Make sure ur using all the including statements.

提交回复
热议问题