Entity Framework Core 2.1 中的 ReverseEngineeringGenerator
ReverseEngineeringGenerator in Entity Framework Core 2.1
基于 Mr Rowan Miller 的 this article 我想通过代码使用 EF Core 脚手架系统。
// Add base services for scaffolding
var serviceCollection = new ServiceCollection()
.AddScaffolding()
.AddLogging();
// Add database provider services
var provider = new SqlServerDesignTimeServices();
provider.ConfigureDesignTimeServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
var generator = serviceProvider.GetService<ReverseEngineeringGenerator>();
var options = new ReverseEngineeringConfiguration
{
ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=Northwind;Integrated Security=true",
ProjectPath = @"C:\temp\",
ProjectRootNamespace = "My.Namespace"
};
generator.GenerateAsync(options).Wait();
但它不适用于最新的 EF Core 2.1。
谁能帮我更新代码? (更新的文章)
此处提供 2.1 的代码:https://github.com/ErikEJ/SqlCeToolbox/blob/master/src/GUI/ReverseEngineer20/EFCoreReverseEngineer.cs
var scaffolder = serviceProvider.GetService<IReverseEngineerScaffolder>();
var scaffoldedModel = scaffolder.ScaffoldModel(...
var filePaths = scaffolder.Save(scaffoldedModel,...
基于 Mr Rowan Miller 的 this article 我想通过代码使用 EF Core 脚手架系统。
// Add base services for scaffolding
var serviceCollection = new ServiceCollection()
.AddScaffolding()
.AddLogging();
// Add database provider services
var provider = new SqlServerDesignTimeServices();
provider.ConfigureDesignTimeServices(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
var generator = serviceProvider.GetService<ReverseEngineeringGenerator>();
var options = new ReverseEngineeringConfiguration
{
ConnectionString = @"Server=(localdb)\mssqllocaldb;Database=Northwind;Integrated Security=true",
ProjectPath = @"C:\temp\",
ProjectRootNamespace = "My.Namespace"
};
generator.GenerateAsync(options).Wait();
但它不适用于最新的 EF Core 2.1。
谁能帮我更新代码? (更新的文章)
此处提供 2.1 的代码:https://github.com/ErikEJ/SqlCeToolbox/blob/master/src/GUI/ReverseEngineer20/EFCoreReverseEngineer.cs
var scaffolder = serviceProvider.GetService<IReverseEngineerScaffolder>();
var scaffoldedModel = scaffolder.ScaffoldModel(...
var filePaths = scaffolder.Save(scaffoldedModel,...