刚把项目升级到2012,发现发生了很多变化,以下是最近看过的网站和资料汇集,供需要者参考。
本文在最近一个月可能会不断更新。
var users = new UsersContext().UserProfiles.ToList();
userContext.UserProfiles.Remove(user); userContext.SaveChanges();
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); AuthConfig.RegisterAuth(); ... WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); }另外在一个叫做 FilterConfig.cs文件中,请加上第二句话:
public class FilterConfig { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); filters.Add(new InitializeSimpleMembershipAttribute()); } }原文见: http://stackoverflow.com/questions/12342398/simplemembership-mvc4-authorizeattribute-and-roles
@{ Layout = "~/Views/Shared/_Layout.cshtml"; }
Layout = "~/Views/Shared/_Layout.cshtml";这句话,在任何其他地方设置Layout可能会导致错误,但不报错!只是从此处以后的内容不再显示。
Layout = "~/Views/Shared/_Layout.cshtml";
In Server Explorer, choose the Connect to Database button.
In the Add Connection dialog box, specify the following information:
Data Source: Microsoft SQL Server (SqlClient)
Server Name: (LocalDB)\v11.0
Attach a database file: Path, where Path is the physical path of the primary .mdf file.
Logical Name: Name, where Name is the name that you want to use with the file.
Choose the OK button.
When prompted, choose the Yes button to upgrade the file.