Entity framework 首先使用实体框架代码时,是否可以为不使用fluent API时创建的多对多链接表指定模式?
我有两个实体:配方和配料 实体:Entity framework 首先使用实体框架代码时,是否可以为不使用fluent API时创建的多对多链接表指定模式?,entity-framework,ef-code-first,many-to-many,Entity Framework,Ef Code First,Many To Many,我有两个实体:配方和配料 实体: public class Ingredient { public int IngredientId{get;set;} public string Name {get;set;} public virtual ICollection<Recipe> Recipies {get;set;} } public class Recipe { public int RecipeId{get;set;} public
public class Ingredient
{
public int IngredientId{get;set;}
public string Name {get;set;}
public virtual ICollection<Recipe> Recipies {get;set;}
}
public class Recipe
{
public int RecipeId{get;set;}
public string Name {get;set;}
public virtual ICollection<Ingredient> Ingredients {get;set;}
}
。。。一切正常。唯一的问题是生成的多对多表是在“dbo”模式中创建的
dbo.接收元件
如果不在Fluent API中定义关系,是否有办法将“Web”指定为多对多表使用的表模式?否。数据注释仅支持映射功能的基本子集。如果您想拥有完整的代码优先映射特性集,您必须使用fluentapi(这也是定义映射的更简洁的方法)。定义与连接表相关的任何内容都被视为高级映射功能,目前仅在Fluent API中可用。感谢您的快速回复。我花了额外的10分钟来定义我的所有映射,这毕竟不是那么糟糕。
ToTable( "Recipe", "Web" );
ToTable( "Ingredient", "Web" );