Basic CRUD operations on Azure DB from MVC 5 application azure azure-sql-database c# entity-framework-6


I have built a very basic mvc application. I need it to have basic CRUD functionality. My database is located on Azure. When I try to create a new record in my mvc application it does not load into my Azure database. I followed the tutorial on the Microsoft website for using EF6. I used scaffolding to create the new view and controller once I connected the Azure database and none of the crud functionality works. This is the code for the "create" portion

        // POST: Venues/Create
    // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
    // more details see
    public ActionResult Create([Bind(Include = "VenueID,VenueName,VenueAdd,VenueCity,VenueState,VenueCountry,VenueCounty,VenueZip,VenuePhone,VenueFax,VenueContactName,VenueContactEmail,VenueContactPhone,VenueWebsite,VenueLat,VenueLong,VenueRating")] Venue venue)

            if (ModelState.IsValid)
                return RedirectToAction("Index");

        return View(venue);

It is very basic that is why I am not sure why it isn't working This is the link I want to function

The Azure database is empty. I have used the ado entity model in visual studio to connect to the database. It is an .edmx file

ok this may help a lot - I was able to step through the code and I received this exception

Message = "Unable to update the EntitySet 'Venue' because it has a DefiningQuery and no element exists in the element to support the current operation."

So it looks as if there is no insert function - at least that is what I am thinking but wasn't that created when I did the scaffolding?

7/13/2017 10:33:32 PM

Accepted Answer

What had happened is somehow the primary key of the model was not created. I created the primary key and all of the CRUD functionality was there. Thank you for all the help

7/13/2017 11:07:46 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow