我正在尝试从默认的MVC 4 Internet应用程序更新简单身份验证。我的问题是我的主机提供程序附加了一个用户名作为我创建的表的模式,所以我没有dbo.UserProfile,而是有一个username.UserProfile表。
在AccountModels.cs文件中,我已将TableAttribute更新为[Table(“username.UserProfile”)]而不仅仅是[Table(“UserProfile”)],它应该更改根据本文使用的模式({{ 3}})。
虽然在运行应用程序时我仍然遇到实体框架错误。
System.Data.SqlClient.SqlException(0x80131904):无效的对象名称'dbo.username.UserProfile'。
所以它仍然附加dbo作为架构......任何人都有任何想法?
谢谢!
答案 0 :(得分:1)
尝试[Table("UserProfile", Schema = "username")]
- 架构有一个单独的属性。
(我认为你可能会因为查看错误命名空间下的文档而被绊倒;你提供的链接是System.Data.Linq.Mapping.TableAttribute
类,而不是System.ComponentModel.DataAnnotations.Schema
中的类。他们使用重复的类名!!)