-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Feature suggestion: Migrations #4
Comments
Hi Michael Of course migrations support would be great.
It seems very complicated to me and may there is another way to do this. |
I agree - it would be great, but it does not seem to be an easy task. It may be planned for a future release... |
Migrations would be ideal, as that seems to be how EF is typically presented with Code First. Is there some documentation on how to use EF with Code First but not with migrations? Everything I find seems to discuss migrations (which requires the above-mentioned sql generator class). When I try running "update-database", it asks for the sql generator. I'm sorry if this isn't the right forum for this question, but how do I use this project and SQLite without migrations? I have this working as code-first (with migration) in SQL Server, but wanted to try SQLite, as the db is small and SQL Server is overkill. |
Hi Gary
I once tried to dive into EF and find out how the migrations are implemented. In the (Issue 16)[https://github.com//issues/16] HareIM posted a link with an implementation for such an sql generator. May you can try to use this: https://drive.google.com/file/d/0B-NCqWnMQpBrQjkxMkxnVlRzb00/view?pli=1 |
Thanks for the fast response, Marc! I think I can probably live without the migrations with my small project, but the Sql Generator sounds intriguing. I'll have a look at that and the sample code you mention as time permits. Working on this last night, I kept getting a zero-byte SQLite database generated, so I must be doing something wrong; it did not re-build a freshly seeded db as I would have expected. Since I have been using SQL Server, it seems to hang on to that information somewhere. When I run, it creates a zero byte SQLite db, but then runs off of the SQL Server db! (I've commented-out the connection strings in the web.config for SQL Server, so not sure how it does that!) I like how EF automates things, but I guess it also hides what it's doing. (In other work, I use DB-first, and I think that's best for larger projects. I've had success working with that, so I've been tempted to go that route.) If I continue to be stuck, I'll just start over with a "fresh" project and copy files over, to ensure that it only uses SQLite. Thanks for clarifying things. |
+1 |
I've got a working prototype for migrations. It was originally based on the prototype put together by Julio C. Borges in 2013, although significant further work was required. Several migration operations are currently not implemented, notably those ALTER TABLE operations which are not natively supported by SQLite (see https://www.sqlite.org/lang_altertable.html). The code is not as clean or well-formatted as I'd like for issuing a pull request, so for the time being you can get it here: https://github.com/zanyants/SQLiteCodeFirst/tree/feature/migrations To use: To your migrations Configuration class ctor, add:
And in your context's
|
Hello Tom Thanks for your work! I created a branch https://github.com/msallin/SQLiteCodeFirst/tree/Issue-4 you can create a PR to push your changes in this branch and then we can work on it. Greetings Marc |
Hi Marc, I'm also rather busy - I should have time to do as you ask early next week. Tom |
If it is any consolation, EF7 hasn't gotten very far with this ... https://github.com/aspnet/EntityFramework/blob/dev/src/Microsoft.EntityFrameworkCore.Sqlite/Migrations/SqliteMigrationsSqlGenerator.cs#L149 |
More (actually, less progress but more discussion) from the EF team not getting far with SQLite migrations. This issue has links to a lot of other related issues in the EF7 project. It seems to be the main issue they are tracking on the matter. |
Any updates on this? I think it's almost the only open issue left... :-) |
I was wondering how the fact that SQLite is supported using .Net Core and EF.Core would affect this issue. see here: https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite |
I while ago I looked through the code (as its OSS :)) but I noticed thats not just "take and use". I think this is a lot of work to do and I'm currently not planning to work on it by my self. |
I'm using @tg73 work and is working fine, with some adjusts on index names. |
Apologies for my slow reply. The migrations work I did was done as part of
my employed work. It was a limited project and I've since moved on to
completely unrelated work, and unfortunately have no time allocated for
further SQLite/migrations work. I was keen to get my original work
contributed back to the community in case it was of use, and I hope it can
be taken further. I seem to remember getting to a point where the
limitations of SQLite required quite complex workarounds, possibly
requiring a lexer/parser of SQLite flavour SQL to properly support some
part of the migrations workflow.
…On 1 March 2017 at 11:37, digocesar ***@***.***> wrote:
I'm using @tg73 <https://github.com/tg73> work and is working fine, with
some adjusts on index names.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABDPfRb5Brn_1t7d3cKM9r22Bv0KvIzNks5rhViSgaJpZM4D1sY->
.
|
Maybe worth to have a look: |
Hi @msallin Excellent work on this Library! Love it!! I just tried to do an What's the point of using this for Code-First, if migrations is not supported. In any practical real-life project, the database is not just created 1 time and forgotten. It will undergo many changes during it's lifetime. Any chance anyone else will be able to take this on? Thank you! |
The ASP.NET team are still onto this: dotnet/efcore#7969 as well as the previously mentioned dotnet/efcore#329 I have been thoroughly distracted by client work, those pesky rascals, so have been unable to dive into this. Yet. :( |
Hi @Rgl88 , |
Hi @AndreaMarchetto ,
UPDATE
=> keep data and add new field |
Hello @tuanth89 |
Hello @tuanth89 |
Just leaving this here so I don't lose it - looks useful ... |
Anyone have this issue? |
Hi @JobaDiniz . |
Yes, I've changed. It works for EF 6.1.x but not for 6.2.x
…On qui, 10 de mai de 2018 at 15:14 digocesar ***@***.***> wrote:
Hi @JobaDiniz <https://github.com/JobaDiniz> .
Did you changed the Database Initializer?
See if this
<https://github.com/digocesar/SQLiteCodeFirst#sqlitemigrationsqlgenerator-sample>
information can help you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKFqpAKgZEXvvMURWshusr4QDQHjl7eks5txIOUgaJpZM4D1sY->
.
|
@msallin is this link correct? it goes to the home page of this repository... |
Points to the branch #4, into which I merged your PR. I'll need some time to look through the code and I'll merge it into the master as soon as EF 6.3 with the fix was released and I integrated it into SQLite.CodeFirst. |
I integrated your library using nuget package manager, have two questions : |
Ok, I'm sure missing few things : `public class BHDBContext : DbContext
and
so, as much as i thought, it should create the data base if it does not exist when ever i am calling the dbcontext for an instantiation? guess what, nothing is happening, no data base at all ! |
EF 6.3 with the necessary fix isn't yet released. |
Please create a new issue for this and upload the code somewhere (only what's necessary to reproduce), then I'll have a look at it. |
I haven't followed this up but apparently SQLite v 3.25.0 introduced renaming columns and fixed some table renaming problems: https://stackoverflow.com/questions/805363/how-do-i-rename-a-column-in-a-sqlite-database-table/52346199#52346199 |
System.Data.SQLite.EF6.Migrations comes out. |
Did anybody use System.Data.SQLite.EF6.Migrations? If yes, does it completely replace this library or is there anything you can't do? I'm not very emotional to deprecate, if there is a better option. |
I found System.Data.SQLite.EF6.Migrations at https://github.com/bubibubi/sqliteef6migrations. It doesn't seem to replace your library, I didn't look at it closely. I need to continue to use .NET framework for most of my projects so even if you deprecate this I will stay with it. I use a manual SQL / Reflection thing based on .. https://github.com/semashkinvg/SQLiteCodeFirst/blob/master/SQLite.CodeFirst.Console/FootballDbInitializer.cs ... well, sort of. Wow, I can't figure out where all that came from and it was only 9 months ago. My Trello card for it has lots of links and notes. It makes a lot o use of |
I rebased and squashed the branch containing the migrations code from @digocesar and dropped net4.0 support. I didn't test it but if anybody wants to continue, feel free. Artifacts for testing are here: https://ci.appveyor.com/project/msallin/sqlitecodefirst/build/job/gy8s20q6fak8804r/artifacts |
I had to add this code to
exception thrown before adding the code:
|
What do you think about migrations-support?
The text was updated successfully, but these errors were encountered: