EFCorePowerTools: Reverse Engineer - EF Core 5 Model generator probleme
When I use the Reverse Engineer for EF Core 5 there are no longer the Table and Shcema attributes in the model classes. So that in the generated SQL the shema is missing and sql server returns => Invalid object name ‘xxxx’.
Steps to reproduce
Example of model class with Reverse Engineer EF Core 3
[Table("MesEtatAcquisition", Schema = "Acq")]
public partial class MesEtatAcquisition
{
public MesEtatAcquisition()
{
MesAcquisition = new HashSet<MesAcquisition>();
}
[Key]
public int NoEtat { get; set; }
[Required]
[StringLength(50)]
public string RefEtat { get; set; }
[Required]
[StringLength(50)]
public string LbEtat { get; set; }
[InverseProperty("NoEtatNavigation")]
public virtual ICollection<MesAcquisition>
MesAcquisition { get; set; }
}
Example of model class with Reverse Engineer EF Core 5
public partial class MesEtatAcquisition
{
public MesEtatAcquisition()
{
MesAcquisition = new HashSet<MesAcquisition>();
}
[Key]
public int NoEtat { get; set; }
[Required]
[StringLength(50)]
public string RefEtat { get; set; }
[Required]
[StringLength(50)]
public string LbEtat { get; set; }
[InverseProperty("NoEtatNavigation")]
public virtual ICollection<MesAcquisition>
MesAcquisition { get; set; }
}
I manually added the table and shema row in the class generated in EF Core 5 and the generated SQL query is correct.
So I think we need to add the Table and shema attributes to the model class generated in Reverse Engineer for EF Core 5
thank you in advance
Further technical details
EF Core Power Tools version: 2.5.454.0
SQLite ADO.NET Provider included: 1.0.109.0 SQLite EF6 DbProvider in GAC - No
System.Data.SQLite DDEX provider - No SQLite Simple DDEX provider - Yes
Database engine: (SQL Server)
Visual Studio version: (e.g. Visual Studio 2019 Version 16.8.2)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (10 by maintainers)
You are using Handlebars, and the templates must be initialized and redone for 5.0 (breaking change) - renaming the CodeTemplates folder in your repro project fixes the issue. (Or stop using Handlebars)