I'm working with creating a partial view to allow the end user to add an item for a later submission.
I have the following class defined as a ViewModel:
public class AddItemsContext : DbContext
{
public DbSet<Item> Items { get; set; }
}
Connection string:
I then have an AJAX call that uses this function to add an item to my partialview:
[HttpPost]
public ActionResult Index_AddItem(SearchedItem viewModel, string Text, string Value)
{
AddItemsContext db = new AddItemsContext();
string test = Request.Form.GetValues("cbxPerm")[0].ToString(); // to be used later
Item NewItem = new Item();
NewItem.ItemName = "test"; // just set it to a temp var for testing
db.Items.Add(NewItem);
db.SaveChanges();
return PartialView("_AddItems", db.Items);
}
The item list does build in my partial view but then I noticed the list persists even after stopping and restarting my app. I thought it may be writing in the SQL DB but I don't see it there either.
I found this: where is data stored? but I don't have any other datasource defined other than my main app's DB.
I also read this: DbContext disposing? which appears to be saying that the data should be disposed on exit.
This partial view needs to add/remove items before the form is submitted for a DB write.
I'm trying to understand why/where the data is being stored permanently?