-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using generated datamodel in unit tests with SQLite #795
Comments
How about modifying the code to remove the `.HasColumnType()" addition? Delete the following: if (Column.ExcludedHasColumnType.Contains(c.SqlPropertyType))
excludedHasColumnType = string.Format(" // .HasColumnType(\"{0}{1}\") was excluded", c.SqlPropertyType, columnTypeParameters);
else
sb.AppendFormat(".HasColumnType(\"{0}{1}\")", c.SqlPropertyType, columnTypeParameters); There are two places, one for EF6 and one for EFCore. |
Yeah, that would work too. I guess I'm losing out on something when skipping the HasColumnType but I'm not sure exactly what. EDIT: Got into some issues with datetime formatting having removed the HasColumnType. I'll look into it. |
I was thinking of adding a flag to skip generating the |
We use datetime (as opposed to datetime2) in several columns in our db. EF Core for SQL Server defaults to datetime2 unless we use HasColumnType to tell it to use datetime. Without specifying that we really wantthe datetime rather than the datetime2 EF Core fails to serialize/deserialize our datetime columns. My current way around this was to add some types to the ExcludedHasColumnType: public static readonly List<string> ExcludedHasColumnType = new List<string>
{
"user-defined",
"int",
"varchar(max)",
"nvarchar(max)",
};
|
Hi!
We use SQLite in our unit tests and SQL Server when actually running our application. With some tweeking Reverse POCO works fine with SQLite but there is one little problem remaining. I want to use the same generated datamodel code both when running unit tests and when running the application. Unfortunatly that does not work at the moment since the generated configuration code includes statements that need to be different during runtime for SQLite and SQL Server.
In the method "public void Configure(EntityTypeBuilder builder)" in each class derived from "IEntityTypeConfiguration" there are statements like the following for all integer columns:
Using the tweeking mentioned above I can get that changed to
BUT, I need the same code to configure these columns with type "int" when running the application and with type "integer" when ruinning unit tests. So, it needs to configure differently at runtime depending on the underlying db type.
My current solution to this is to modify your code so that it emits the following (an example):
When running unit tests I set the environment variable UseSQLite to the value true.
This works but it feels rather hackish and awkward. If you could add functionality that resolves this issue in a more fashionable way it would be greatly appreciated.
The text was updated successfully, but these errors were encountered: