Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Issue: Web Tools 2012.2 RC: Unable to Add a Controller with read/write actions using EF [728]

$
0
0
SUMMARY

There seems to be a Web Tools 2012.2 RC regression while adding Controllers with EF CRUD support.
The following scenario works as expected without Web Tools refresh.

ENVIRONMENT INFO

Microsoft Visual Studio Ultimate 2012 Version 11.0.51106.01 Update 1
Microsoft .NET Framework Version 4.5.50709 Web Developer Tools 1.2.31206.0
SQL Express or LocalDB

REPRO

1) Install VS 2012, VS 2012 Update 1, Web Tools 2012.2 RC
2) Create a SQL database and a table "Customer"
3) Create a new MVC4 project, "Internet app"
4) Right click "Models" on Solution Explorer, Add, New item, Data, ADO.Net Entity Data Model, Generate from Database, ... choose "Customer" table
5) Save and compile
6) Verify your Model .cs file
namespace MvcApplication6.Models
{
using System;
using System.Collections.Generic;
public partial class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public Nullable<int> Balance { get; set; }
}
}


7) Verify your Context contains a DbSet<Customer> property
namespace MvcApplication6.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class TestEntities : DbContext
{
public TestEntities()
: base("name=TestEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<Customer> Customers { get; set; }
}
}

8) Right click "Controllers" on Solution Explorer, Add, Controller, "MVC with CRUD using EF", choose your entity class (Customer) and container (TestEntities) from dropdowns

EXPECTED

A new controller.

RESULT

Error: 'MvcApplication6.Models.Customer' is not part of the specified 'MvcApplication6.Models.TestEntities' class, and the 'MvcApplication6.Models.TestEntities' class could not be modifed to add a 'DbSet<MvcApplication6.Models.Customer>' property to it. (For example, the 'MvcApplication6.Models.TestEntities' class might be in a compiled assembly.)




Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>