I'm creating the following table on PostgreSQL:
create table dbo.user_ratings (
user_id int not null,
user_rated_id int not null,
value decimal not null,
status_id int not null,
created_at timestamp with time zone not null,
updated_at timestamp with time zone null,
user_comment text null,
primary key (user_id, user_rated_id),
foreign key (user_id) references dbo.users(id),
foreign key (status_id) references dbo.status(id),
foreign key (user_rated_id) references dbo.users(id));
When mapping the table using CodeFirst, I'm doing the following:
[Table("user_ratings", Schema="dbo")]
public class UserRating {
[Key, Column("user_id", Order = 0)]
public int UserId { get; set; }
public virtual User User { get; set; }
[Key, Column("user_rated_id", Order = 1)]
public int UserRatedId { get; set; }
public virtual User UserRated { get; set; }
[Column("status_id")]
public int StatusId { get; set; }
public virtual Status Status { get; set; }
public decimal Value { get; set; }
[Column("user_comment")]
public string UserComment { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
[Column("updated_at")]
public DateTime UpdatedAt { get; set; }
}
Well, so far, so good. When I try to query something, I'm getting the error below:
Column names in each table must be unique. Column name 'User_Id' in table 'user_ratings' is specified more than once.
What is wrong with this? When I remove the mapping related to the column user_id
, it's passing, but it's not right. Can someone help me?
Thank you all!!!
Seems that this error is related only to SQLServer databases. I still had some SQLServer configurations on my Web.config/App.config, that's why this error was appearing. Without SQLServer configurations, the error is gone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.