-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
EF Core Power Tools - Sqlite data types different than those created in EF 6.0 #654
Comments
Another difference between EF6 reverse engineering is that I have a table named Segment, and another one called Field. A field has a navigation property to Segment. Instead of the name being Field.Segment as it was in EF6, it called is Field.SegmentNameNavigation
This is the only navigation property that seems to get named differently than EF6. The modelbuilder code generated for this entity is:
|
Could be made better by dotnet/efcore#8824 |
@jonreis Could I ask you to seperate your issues to keep the conversation scoped to a single issue , As @bricelam kindly mentioned, it is a known issue. In EF 6, the System.Data.Sqlite ADO.NET provider was used, it it was better at guessing datatype - also note that in reality, SQLite on has 4 "data types" - https://www.sqlite.org/datatype3.html - none of which are "bit" Regarding the Schemata vs Schemas issue - are you using Pluralization? It is not the same between EF6 and EF Core Power Tools, I assume that could be the cause. |
If have created #656 |
@ErikEJ sorry, yes I should have logged it as a different issue. Thanks for moving it. I had Pluralization on. The table name is Schema to Schemas, instead of Schemata. I actually prefer Schemas, over Schemata, I just pointed it out as an aside. |
There is really nothing for me to do regarding this, so closing |
@ErikEJ you are right about Sqlite only having 4 data types, however; to keep the sql the same between Sql Server and Sqlite, it would be nice to have it mapped correctly. |
I understand, but maybe you should consider another database engine than SQLite then (one that is more stringly typed) - where is SQLite used? |
It is used as a local look up database, and application configuration. It used to be on SqlServerCe and I moved it over to Sqlite because SqlServerCe was problematic. It is wells suited to what it is being used for. We use full SqlServer for our main product. I can always change the database definitions to use only the 4 datatypes that Sqlite supports, or I can just manually fix the model. That is not a problem. I just thought you might like to know that what worked in EF6, no longer works with EFP. |
@jonreis Appreciate the info, thanks! |
Btw - how was SQLCE problematic - maybe I could help your there? |
Thanks for your help Erik. We have already made the transition to Sqlite and have been quite happy with it. Our product sped up quite a bit after moving to Sqlite especially the initial database connection which would pause a few seconds, I think due having encryption turned on. It seems that SQLCE is not being developed anymore and Microsoft seems to be using Sqlite more these days, including in visual studio. Sounds like you think SqlServerCe is still a viable option for new development? It has been a few years, but are a couple of issues my customers had with SqlCE. |
I have blogged about this here: http://erikej.blogspot.dk/2013/08/faq-why-is-opening-my-sql-server.html But you are right, SQLCE is deprecated, it is hard to find a perfect solution to most problems. |
Just wondering, in SQLite/SQL Server Compact Toolbox, you nicely handle the data types. For instance my bit field is shown as a checkbox. So it is nice to keep the "virtual" data types in Sqlite even if they get mapped to a different underlying type. I am assuming from dotnet/efcore#8824, that is is an issue with .NET Core Sqlite provider, and not something with the EFP. Is that correct? I cannot imagine users would want to have to translate the datetime, bit, int, and others manually. |
Yes, this is due to the way EF Core implements reverse engineering for SQLite |
Describe what is not working as expected.
Hello Erik, I just found the EF Core Power Tools and the HandleBar support is awesome! I'm not sure I would be able to use EF Core with a database first approach without it. Thank you so much.
I have having a small problem with the data types that worked fine under EF6 using the Reverse Engineering tool with Sqlite.
Here is the table definition:
-- Script Date: 3/11/2018 1:21 PM - ErikEJ.SqlCeScripting version 3.5.2.75
CREATE TABLE [Schema] (
[SchemaId] INTEGER NOT NULL
, [SchemaVersion] nvarchar(16) NOT NULL
, [DatabaseVersion] nvarchar(16) NOT NULL
, [Expression] ntext NULL
, [Description] nvarchar(1024) NULL
, [ReadOnly] bit NOT NULL
, [ModifiedDateTime] datetime NOT NULL
, CONSTRAINT [sqlite_master_PK_Schema] PRIMARY KEY ([SchemaId])
);
In EF6, Readonly was translated into a bool, and ModifiedDateTime was translated into a DateTime.
In EF Core 2.1 (preview) /EF Power Tools 1.0.539 these get translated to strings.
The ModelBuilder code looks like it has the correct types:
Properties.hbs (partial)
+++++++++
Am I doing something wrong, to get strings instead of the proper data types?
Another, very minor issue that doesn't matter is that the DbSet name in EF6 is Schemata, and in EF Core 2.1, it is Schemas
Further technical details
Toolbox/Power Tools version: 1.0.539
Database engine: SQlite
Visual Studio or SSMS version: 15.6.0
The text was updated successfully, but these errors were encountered: