I have 2 entities Course
and Group
which are many-many related. I am using code first migrations. when i update-database -v
it is throwing an exception
I am aware that Many-Many relationship creates another table GroupCourses
.
StackTrace : ALTER TABLE [dbo].[GroupCourses] ALTER COLUMN [Course_CourseId] [int] NOT NULL
Exception : Operand type clash: uniqueidentifier is incompatible with int
public class Course
{
[Key]
public int CourseId { get; set; }
public virtual ICollection<Group> Groups { get; set; }
}
public class Group
{
[Key]
public Guid groupId { get; set; }
public virtual ICollection<Course> Courses{ get; set; }
}
I think it is due to different PK types in both entities. Am i correct? If yes, is there any solution to overcome this.
Thanks in Advance.