Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:12:11+00:00 2026-06-18T04:12:11+00:00

I created a project using the newly Single page application of Asp.Net MVC 4.

  • 0

I created a project using the newly Single page application of Asp.Net MVC 4. I ran the web app and the default Sql Server localDB database is created, as well as the Tables for the following class.

public class TodoItem
{
    public int TodoItemId { get; set; }

    [Required]
    public string Title { get; set; }
    public bool IsDone { get; set; }
    // public string Test { get; set; }

    [ForeignKey("TodoList")]
    public int TodoListId { get; set; }
    public virtual TodoList TodoList { get; set; }
}

}

Then

  1. I found that I need the database generated varchar(max) for column Title. I modified it to varchar(500). (alter table todoitems alter column Title varchar(500) not null) The web app can be run without any problem.
  2. Then I add a new property in the class (uncomment the Test property). I got the following exception when running the web app.

The model backing the ‘TodoItemContext’ context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

on

[Authorize]
public class TodoListController : ApiController
{
    private TodoItemContext db = new TodoItemContext();

    // GET api/TodoList
    public IEnumerable<TodoListDto> GetTodoLists()
    {
        return db.TodoLists.Include("Todos")
            .Where(u => u.UserId == User.Identity.Name)
            .OrderByDescending(u => u.TodoListId)
            .AsEnumerable()
            .Select(todoList => new TodoListDto(todoList));
    }
  1. I tried to modify the database table (alter table todoitems add Test varchar(200)), but the exception is still raised.

Is it possible to change the model class and modify (either by VisualStudio or manully) the table instead of recreate it? (I want to keep my manually changes on the database tables.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:12:13+00:00Added an answer on June 18, 2026 at 4:12 am

    What you’re looking for is called Code First Migrations – you can see a great walk-through on MSDN: http://msdn.microsoft.com/en-us/data/jj591621.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a maven project using a Simple Web App Archetype. Then I went
I have created SQL Server 2008 Database project using visual studio 2010. after build
info: xcode 4.3.2, iOS5, using storyboard. Created project from xcode's Tabbed Application template. Did:
In a newly created Django project I'm using ropemacs to get semantic completions and
Mono 2.10's release notes suggest support for ASP.NET MVC 3.0 and Razor using XSP
I succesfully created a project using seam credentials for authentication, but right now some
I successfully created a project using Wicket quickstart and turned it into an Eclipse
I have recently just created Java project using Eclipse that requires 2 JAR files
I created an iPhone project using the Core Data template. Now when I try
I just created a new project using the visual studio cordova starter template. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.