TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Herlan
NA
215
3k
Migration - FOREIGN KEY constraint
Feb 28 2020 11:07 PM
Hi, I working with Code First when I run the migration I get error.
Introducing FOREIGN KEY constraint 'FK_dbo.Users_dbo.Campaigns_CampaignID' on table 'Users' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint. See previous errors.
Please, I need help, I don't understand why this error happens.
Thanks,
public
class
Message
{
public
int
ID {
get
;
set
; }
public
string
Content {
get
;
set
; }
public
string
Timestamp {
get
;
set
; }
public
int
UserID {
get
;
set
; }
public
virtual
User User {
get
;
set
; }
public
int
RoomID {
get
;
set
; }
public
virtual
Room Room {
get
;
set
; }
}
public
class
Room
{
public
int
ID {
get
;
set
; }
[MaxLength(200)]
public
string
RoomKey {
get
;
set
; }
[StringLength(30, MinimumLength = 3)]
public
string
Name {
get
;
set
; }
public
int
UserCreator {
get
;
set
; }
public
virtual
User User {
get
;
set
; }
public
int
CampaignID {
get
;
set
; }
public
virtual
Campaign Campaign {
get
;
set
; }
public
virtual
ICollection
Messages {
get
;
set
; }
}
public
class
Company
{
public
int
ID {
get
;
set
; }
[StringLength(30, MinimumLength = 3)]
public
string
Name {
get
;
set
; }
public
virtual
ICollection
Campaigns {
get
;
set
; }
}
public
class
Campaign
{
public
int
ID {
get
;
set
; }
[StringLength(50, MinimumLength = 3)]
public
string
Name {
get
;
set
; }
public
int
CompanyID {
get
;
set
; }
public
virtual
Company Company {
get
;
set
; }
public
virtual
ICollection
Users {
get
;
set
; }
public
virtual
ICollection
Rooms {
get
;
set
; }
}
public
class
City
{
public
int
ID {
get
;
set
; }
[StringLength(50, MinimumLength = 3)]
public
string
Name {
get
;
set
; }
public
virtual
ICollection
Users {
get
;
set
; }
}
public
class
User
{
public
int
ID {
get
;
set
; }
[StringLength(50, MinimumLength = 3)]
public
string
UserName {
get
;
set
; }
public
string
Password {
get
;
set
; }
[StringLength(50, MinimumLength = 3)]
public
int
CityID {
get
;
set
; }
public
virtual
City City {
get
;
set
; }
public
int
CampaignID {
get
;
set
; }
public
virtual
Campaign Campaign {
get
;
set
; }
public
int
RoomID {
get
;
set
; }
public
virtual
Room Room {
get
;
set
; }
public
bool
Status {
get
;
set
; }
public
DateTime RegisterDate {
get
;
set
; }
public
int
UserCreator {
get
;
set
; }
}
Reply
Answers (
1
)
How to Compare between Hashed Password
Problem pulling value from empty table