问题描述
我有两个实体(Customer和CustomerRole),并希望声明它们之间的多对多关系。我可以使用以下代码:
I have two entities (Customer and CustomerRole) and would like to declare many-to-many relationship between them. I can do using the following code:
modelBuilder.Entity<CustomerRole>()
.HasMany(cr => cr.Customers)
.WithMany(c => c.CustomerRoles)
.Map(m => m.ToTable("Customer_CustomerRole_Mapping"));
但是它会创建关系(和第三个映射表),并且级联删除切换默认情况下关闭。如何在使用多对多时告诉EF创建与级联删除关系的关系?
But it creates the relationship (and the third mapping table) with cascade delete switched off by default. How can I tell EF to create the relationship with cascade delete switched on when using many-to-many?
推荐答案
欢迎来到MSDN论坛,感谢您在此发帖。
Welcome to the MSDN Forum and thank you for posting here.
在我看来,您的问题是EF预发布相关案例,因此我会将其移至正确的论坛,以确保您获得更好的支持。
In my opinion, your question is a EF pre-release related case, so I will move it to the right forum to make sure you can get a better support.
感谢您的理解和支持!
祝你有愉快的一天,
这篇关于实体框架CTP5,代码优先。有多个级联删除。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!