Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Commented Unassigned: SQL CE :: when trying to scaffold a migration that uses MapToStoredProcedures on SQL CE, we create migration with empty body, rather than throwing earlier [1154]

$
0
0
I have a simple model targeting Sql CE:

public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
}

public class MyContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
}



I scaffold a migration, all works fine.

Then I try to add mapping to stored procedures:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>().MapToStoredProcedures();
}



Wen I scaffold a new migration, we create something like this:


public override void Up()
{
CreateStoredProcedure(
"Customer_Insert",
p => new
{
Name = p.String(maxLength: 4000),
},
body: ""
);

CreateStoredProcedure(
"Customer_Update",
p => new
{
Id = p.Int(),
Name = p.String(maxLength: 4000),
},
body: ""
);

CreateStoredProcedure(
"Customer_Delete",
p => new
{
Id = p.Int(),
},
body: ""
);


Which throws the following error during Update-Database:




at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass9.<Update>b__8()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

__The argument 'body' cannot be null, empty or contain only white space.__


Sql CE does not support Stored procs, so I don't expect this to work, but I would expect for us to fail more gracefully (detect that we are targeting CE and throw before scaffolding a corrupted migration)
Comments: This is just a bug - The fluent APIs should not validate the body parameter; it is allowed to be null or whitespace. I have a fix for this already so we should just triage it for EF6.

Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>