When making multiple calls to MapToStoredProcedures, we override the previous map stored proc settings. This is a bit confusing. For instance:
``` C#
modelBuilder
.Entity<Blog>()
.MapToStoredProcedures(s =>
s.Update(u => u.HasName("modify_blog")));
modelBuilder
.Entity<Blog>()
.MapToStoredProcedures(s =>
s.Delete(d => d.HasName("delete_blog")));
modelBuilder
.Entity<Blog>()
.MapToStoredProcedures(s =>
s.Insert(i => i.HasName("insert_blog")));
```
will only change name for the Insert stored proc. Other two will be ignored. We should be keeping the previous settings as well.
Comments: Scenario is still broken, throwing NullReferenceException with the following stack trace: System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionConfiguration.Merge(System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionConfiguration modificationFunctionConfiguration, bool allowOverride) System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration.Merge(System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration modificationFunctionsConfiguration, bool allowOverride) System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.MapToStoredProcedures(System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration modificationFunctionsConfiguration, bool allowOverride) System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Verify934.Blog>.MapToStoredProcedures(System.Action<System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration<Verify934.Blog>> modificationFunctionMappingConfigurationAction) Verify934.MyContext.OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) EntityFramework.dll!System.Data.Entity.DbContext.CallOnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder() System.Data.Entity.Internal.LazyInternalContext.CreateModel(System.Data.Entity.Internal.LazyInternalContext internalContext) System.Data.Entity.Internal.RetryLazy<System.Data.Entity.Internal.LazyInternalContext,System.Data.Entity.Infrastructure.DbCompiledModel>.GetValue(System.Data.Entity.Internal.LazyInternalContext input) System.Data.Entity.Internal.LazyInternalContext.InitializeContext() System.Data.Entity.Internal.LazyInternalContext.CodeFirstModel.get() System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(System.Data.Entity.DbContext context, System.Xml.XmlWriter writer) ------------------------------------------------------------------------------------------------------------------ Here is a complete, standalone repro code: public class Blog { public int Id { get; set; } public string Title { get; set; } } public class MyContext : DbContext { protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder .Entity<Blog>() .MapToStoredProcedures(s => s.Update(u => u.HasName("modify_blog"))); modelBuilder .Entity<Blog>() .MapToStoredProcedures(s => s.Delete(d => d.HasName("delete_blog"))); } } class Program { static void Main(string[] args) { using (var context = new MyContext()) { var sb = new StringBuilder(); EdmxWriter.WriteEdmx(context, XmlWriter.Create(sb)); } } }
``` C#
modelBuilder
.Entity<Blog>()
.MapToStoredProcedures(s =>
s.Update(u => u.HasName("modify_blog")));
modelBuilder
.Entity<Blog>()
.MapToStoredProcedures(s =>
s.Delete(d => d.HasName("delete_blog")));
modelBuilder
.Entity<Blog>()
.MapToStoredProcedures(s =>
s.Insert(i => i.HasName("insert_blog")));
```
will only change name for the Insert stored proc. Other two will be ignored. We should be keeping the previous settings as well.
Comments: Scenario is still broken, throwing NullReferenceException with the following stack trace: System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionConfiguration.Merge(System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionConfiguration modificationFunctionConfiguration, bool allowOverride) System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration.Merge(System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration modificationFunctionsConfiguration, bool allowOverride) System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.MapToStoredProcedures(System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration modificationFunctionsConfiguration, bool allowOverride) System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Verify934.Blog>.MapToStoredProcedures(System.Action<System.Data.Entity.ModelConfiguration.Configuration.ModificationFunctionsConfiguration<Verify934.Blog>> modificationFunctionMappingConfigurationAction) Verify934.MyContext.OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) EntityFramework.dll!System.Data.Entity.DbContext.CallOnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder) System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder() System.Data.Entity.Internal.LazyInternalContext.CreateModel(System.Data.Entity.Internal.LazyInternalContext internalContext) System.Data.Entity.Internal.RetryLazy<System.Data.Entity.Internal.LazyInternalContext,System.Data.Entity.Infrastructure.DbCompiledModel>.GetValue(System.Data.Entity.Internal.LazyInternalContext input) System.Data.Entity.Internal.LazyInternalContext.InitializeContext() System.Data.Entity.Internal.LazyInternalContext.CodeFirstModel.get() System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(System.Data.Entity.DbContext context, System.Xml.XmlWriter writer) ------------------------------------------------------------------------------------------------------------------ Here is a complete, standalone repro code: public class Blog { public int Id { get; set; } public string Title { get; set; } } public class MyContext : DbContext { protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder .Entity<Blog>() .MapToStoredProcedures(s => s.Update(u => u.HasName("modify_blog"))); modelBuilder .Entity<Blog>() .MapToStoredProcedures(s => s.Delete(d => d.HasName("delete_blog"))); } } class Program { static void Main(string[] args) { using (var context = new MyContext()) { var sb = new StringBuilder(); EdmxWriter.WriteEdmx(context, XmlWriter.Create(sb)); } } }