Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未为实体框架中的存储过程生成脚本_C#_Sql_.net_Sql Server_Entity Framework - Fatal编程技术网

C# 未为实体框架中的存储过程生成脚本

C# 未为实体框架中的存储过程生成脚本,c#,sql,.net,sql-server,entity-framework,C#,Sql,.net,Sql Server,Entity Framework,我使用实体框架使用以下代码创建数据库脚本: var dbScript = ((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript(); 我在实体映射类中使用MapToStoredProcedure()方法。这段代码只生成了一个CREATETABLESQL脚本,没有为存储过程生成sql脚本 如何为存储过程生成SQL脚本?ObjectContext.CreateDatabaseScript()是一个旧的代码路径,因为数

我使用实体框架使用以下代码创建数据库脚本:

var dbScript = ((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript();
我在实体映射类中使用
MapToStoredProcedure()
方法。这段代码只生成了一个CREATETABLESQL脚本,没有为存储过程生成sql脚本


如何为存储过程生成SQL脚本?

ObjectContext.CreateDatabaseScript()是一个旧的代码路径,因为数据库创建现在使用迁移管道创建架构。因此,CreateDatabaseScript不知道如何处理存储过程。 使用此代码:

var configuration = new DbMigrationsConfiguration
{
    AutomaticMigrationsEnabled = true,
    ContextType = typeof(MyContext),
    MigrationsAssembly = typeof(MyContext).Assembly
};

var migrator = new DbMigrator(configuration);

var scriptor = new MigratorScriptingDecorator(migrator);
string script = scriptor.ScriptUpdate(sourceMigration: null, targetMigration: null);

Console.WriteLine(script);

ObjectContext.CreateDatabaseScript()是一个旧的代码路径,因为数据库创建现在使用迁移管道来创建架构。因此,CreateDatabaseScript不知道如何处理存储过程。 使用此代码:

var configuration = new DbMigrationsConfiguration
{
    AutomaticMigrationsEnabled = true,
    ContextType = typeof(MyContext),
    MigrationsAssembly = typeof(MyContext).Assembly
};

var migrator = new DbMigrator(configuration);

var scriptor = new MigratorScriptingDecorator(migrator);
string script = scriptor.ScriptUpdate(sourceMigration: null, targetMigration: null);

Console.WriteLine(script);

ObjectContext.CreateDatabaseScript()是一个旧的代码路径,因为数据库创建现在使用迁移管道来创建架构。因此,CreateDatabaseScript不知道如何处理存储过程。 使用此代码:

var configuration = new DbMigrationsConfiguration
{
    AutomaticMigrationsEnabled = true,
    ContextType = typeof(MyContext),
    MigrationsAssembly = typeof(MyContext).Assembly
};

var migrator = new DbMigrator(configuration);

var scriptor = new MigratorScriptingDecorator(migrator);
string script = scriptor.ScriptUpdate(sourceMigration: null, targetMigration: null);

Console.WriteLine(script);

ObjectContext.CreateDatabaseScript()是一个旧的代码路径,因为数据库创建现在使用迁移管道来创建架构。因此,CreateDatabaseScript不知道如何处理存储过程。 使用此代码:

var configuration = new DbMigrationsConfiguration
{
    AutomaticMigrationsEnabled = true,
    ContextType = typeof(MyContext),
    MigrationsAssembly = typeof(MyContext).Assembly
};

var migrator = new DbMigrator(configuration);

var scriptor = new MigratorScriptingDecorator(migrator);
string script = scriptor.ScriptUpdate(sourceMigration: null, targetMigration: null);

Console.WriteLine(script);