KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am designing my database using code first and I need a little help I think. I am getting this error: Introducing FOREIGN KEY constraint 'SalesOrder_Invoices' on table 'Invoices' 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. I am trying to have the following relationships/keys: --> = 1 to Many Relationship Customer --> CustomerLocation CustomerLocation --> SalesOrder SalesOrder --> Invoice SalesRep --> SalesOrder PaymentTerm --> Customer PaymentTerm --> SalesOrder PaymentTerm --> Invoice I am trying to define them by the standard of: <ClassName><PrimaryKeyID> Example: Customer has ID property, so in CustomerLocation i define the foreign key like so: Public Property CustomerID AS Integer All I have to do is define the foreign key correct? Do I also have to have navigation properties for each key I define? And, can I not have multiple foreign keys on the same primary key of an object? Updated So to define a relationship, do you use the ClassName.PrimaryKeyProperty ? or do you use navigation properties? Or both? Confused!! Update 2 So to make a relationship work you have to define both sides... I think. Public Class Customer Public Property ID AS Integer Public Overrideable Property Locations AS ICollection(OF CustomerLocation) End Class Public Class CustomerLocation Public Property ID AS Integer Public Property CustomerID AS Integer End Class
Tags (comma-separated)
Save Edits
Cancel