Open yuvarajvelmurugan opened 4 years ago
If haven't tested this yet (though I will later today for just the TblUnitOfMeasurement
type; though I have to skip the scaffolding step because you did not post the CREATE TABLE
script for the underlying table), but the 2.2.6
scaffolded code contains issues, that have been fixed in 3.0.0
.
For example the following line in your FoodDbContext
class was scaffolded in a faulty way:
.HasDefaultValueSql("'current_timestamp()'")
This was fixed in #896 and should not use single quotes:
.HasDefaultValueSql("current_timestamp()")
There also seems to be a problem with the default value of bit
columns because the following code is being generate, which is wrong as well:
.HasDefaultValueSql("'b\\'1\\''");
The code should look like the following line instead:
.HasDefaultValueSql("b'1'");
This time this is likely still an issue in the current 3.0.0
release.
If haven't tested this yet (though I will later today for just the
TblUnitOfMeasurement
type; though I have to skip the scaffolding step because you did not post theCREATE TABLE
script for the underlying table), but the2.2.6
scaffolded code contains issues, that have been fixed in3.0.0
.For example the following line in your
FoodDbContext
class was scaffolded in a faulty way:.HasDefaultValueSql("'current_timestamp()'")
This was fixed in #896 and should not use single quotes:
.HasDefaultValueSql("current_timestamp()")
There also seems to be a problem with the default value of
bit
columns because the following code is being generate, which is wrong as well:.HasDefaultValueSql("'b\\'1\\''");
The code should look like the following line instead:
.HasDefaultValueSql("b'1'");
This time this is likely still an issue in the current
3.0.0
release.
CREATE TABLE tblUnitOfMeasurement
(
ID
tinyint(4) NOT NULL AUTO_INCREMENT,
Title
varchar(50) NOT NULL,
Description
varchar(500) NOT NULL,
Tag
varchar(100) NOT NULL,
Unit
varchar(50) NOT NULL,
Symbol
varchar(10) NOT NULL,
SystemOfMeasurement
varchar(50) NOT NULL,
IsActive
bit(1) NOT NULL DEFAULT b'1',
CreatedOn
timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
ModifiedOn
timestamp NULL DEFAULT NULL,
PRIMARY KEY (ID
)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
I could reproduce the issue while testing it yesterday, but the issue also appears in a much simpler scenario with only one project, one entity with one property and even when specifying wrong a wrong model name.
I will have to check this against a SQL Server table first, but this issue might be unrelated to Pomelo.
I could reproduce the issue while testing it yesterday, but the issue also appears in a much simpler scenario with only one project, one entity with one property and even when specifying wrong a wrong model name.
I will have to check this against a SQL Server table first, but this issue might be unrelated to Pomelo.
I was also facing issue even when ef core was in one project.
I have also posted this issue in Microsoft asp.net forums.
https://forums.asp.net/p/2161604/6284921.aspx?p=True&t=637098986858738711
Steps to reproduce
Create a class library for DAL
Create an asp.net razor application.
Reference the dal project in ui project.
Include below references in DAL project file.
DAL csproj file:
namespace FoodV2.Dal.Models { public partial class TblUnitOfMeasurement { public sbyte Id { get; set; } public string Title { get; set; } public string Description { get; set; } public string Tag { get; set; } public string Unit { get; set; } public string Symbol { get; set; } public string SystemOfMeasurement { get; set; } public bool? IsActive { get; set; } public DateTime CreatedOn { get; set; } public DateTime? ModifiedOn { get; set; } } }
using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata;
namespace FoodV2.Dal.Models { public partial class FoodDbContext : DbContext { public FoodDbContext() { }
}
public void ConfigureServices(IServiceCollection services) { services.AddRazorPages();
dotnet aspnet-codegenerator razorpage -m TblUnitOfMeasurement -dc ../FoodV2.Dal.Models.FoodDbContext -udl -outDir Areas/Admin/Pages/UnitOfMeasurement -namespace FoodV2.UI.Areas.Admin.Pages.UnitOfMeasurement -scripts
dotnet aspnet-codegenerator razorpage -m TblUnitOfMeasurement -dc ../FoodV2.Dal.Models.FoodDbContext -udl -outDir Areas/Admin/Pages/UnitOfMeasurement -namespace FoodV2.UI.Areas.Admin.Pages.UnitOfMeasurement -scripts Building project ... Finding the generator 'razorpage'... Running the generator 'razorpage'... Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable
1 source, Func
2 predicate) at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args) at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args) RunTime 00:00:03.25