Reputation: 139
I'm making an android app with asp.net api
for the database. I got an error do something with the web service.
An error has occurred
Invalid column name 'Location_Id'
Invalid column name 'ApplicationUser_Id'
I checked the migration and why I have Location_Id
instead of LocationId
? And User_Id
too
AddColumn("dbo.Locations", "Location_Id", c => c.Guid());
DropColumn("dbo.Locations", "UserId");
RenameIndex(table: "dbo.Locations", name: "IX_User_Id", newName: "IX_ApplicationUser_Id");
RenameColumn(table: "dbo.Locations", name: "User_Id", newName: "ApplicationUser_Id");
CreateIndex("dbo.Locations", "Location_Id");
AddForeignKey("dbo.Locations", "Location_Id", "dbo.Locations", "Id");
In my domain I didn't type LocationId
with underscore
Here are my Location domain:
[MaxLength(50)]
public string Name { get; set; }
[MaxLength(150)]
public string Address { get; set; }
[MaxLength(250)]
public string Description { get; set; }
public Guid UserId { get; set; }
public ApplicationUser User { get; set; }
public virtual ICollection<UserLocation> UserLocations { get; set; }
public virtual ICollection<Storage> Storages { get; set; }
There's no Location_Id on my Locations. Only Id. I have no idea how to change the column in migration or entity framework. Someone can help?
Thanks :)
Upvotes: 0
Views: 4196
Reputation: 1232
Probably you missed tables relationships setup via ForeignKey attribute or fluent mapping. You can take a look on this question, it could be helpfull.
Upvotes: 3
Reputation: 4002
Its by convention that way but you can actually control it by using [Table("MyTable")]
attribute for the table name and [Column("ColumnName")]
attribute for column name.
Here is an example:
[Table("Affiliates")]
public class Affiliates
{
[Column("AffiliateGUID")]
public Guid AffiliateId { get; set; }
}
Upvotes: 1