zzzprojects / EntityFramework-Classic

Entity Framework Classic is a supported version of the latest EF6 codebase. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.
https://entityframework-classic.net
Other
102 stars 27 forks source link

Migration examples #49

Closed EngrKhizarIqbal closed 4 years ago

EngrKhizarIqbal commented 4 years ago

As per your docs:

Unfortunately, migrations tool for .NET Core is not yet supported by our library. However, you can create a side project in .NET Framework to generate the migrations.

Should anyone please guide me to a link or example explaining how we can achieve this?

Thanks.

JonathanMagnan commented 4 years ago

Hello @EngrKhizarIqbal ,

All you have to do is to create for example a console application (.NET Framework), add entities and generate the migration from it as you would normally do without .NET Core

So you will be able to use this project to generate and apply your migration. It's probably possible to add it to your main project but some additional steps might be required if you don't use the same exact namespace.

Let me know if that answers your question.

Best Regards,

Jonathan

EngrKhizarIqbal commented 4 years ago

It's probably possible to add it to your main project but some additional steps might be required if you don't use the same exact namespace.

That's what we are facing the problem. We have successfully created migrations in a class project with EntityFramework. We are using FluentAPI to configure our entities but we have to create two configurations for each entity. One is to use with Z and others with EntityFramework as when using Z, modelBuilder.Configurations.Add(); expects configuration which inherits from your Z, not from EntityFramework and same goes for the opposite.

If you want, I can share the sample code I've worked on.

JonathanMagnan commented 4 years ago

Sure @EngrKhizarIqbal ,

Please share it here info@zzzprojects.com

JonathanMagnan commented 4 years ago

hello @EngrKhizarIqbal,

Since our last conversation, we haven't heard from you.

Don't hesitate to share your project via our email info@zzzprojects.com

Looking forward to hearing from you,

Jon

EngrKhizarIqbal commented 4 years ago

Hi, I was out of town. I'll share the project tomorrow.

Thanks.

JonathanMagnan commented 4 years ago

Awesome!

thank you for the updates!

Jon

EngrKhizarIqbal commented 4 years ago

Hi @JonathanMagnan, Here is the example code. https://github.com/EngrKhizarIqbal/ef-classic-migrations

JonathanMagnan commented 4 years ago

Hello @EngrKhizarIqbal ,

Just to let you know that we started to look at it.

At first sight, we find it strange that you didn't use the migration directly from EF Classic.

However, when we tried it, we got the following exception:

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'Z.EntityFramework.Classic, Version=7.0.0.0, Culture=neutral, PublicKeyToken=afc61983f100d280' or one of its dependencies. Strong name signature could not be verified.  
The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)"

which seems to be our fault but we are not sure why yet.

We are currently looking at it.

JonathanMagnan commented 4 years ago

Hello @EngrKhizarIqbal ,

A new version has been released (v7.1.20) fixing an issue with the signed key.

However, when I re-read your issue, I'm not sure that changing the dependencies in your EFMigrations project is what you are looking for.

Is the EntityFramework dll is really needed or it was only needed for the EFMigrations project?

If that was only required for the EFMigrations projects then I recommend you remove the dependencies and go all the way with EF Classic. The command line should now work correctly with our library

EngrKhizarIqbal commented 4 years ago

Hi @JonathanMagnan Thanks for the update. Yes, now Migrations are working with the EntityFramework-Classic.

EFMigrations projects are to create migrations as was recommended by EntityFramework-Classic and now this is removed from limitations. I've updated the project, tested it and pushed the updated code on the repo here.

Thanks for your help.

JonathanMagnan commented 4 years ago

Awesome,

So everything is correct? Just to be sure ;)

EngrKhizarIqbal commented 4 years ago

Yes. Everything is working as expected.

Thanks.

JonathanMagnan commented 4 years ago

Awesome @EngrKhizarIqbal,

We will close this issue since we were able to solve it! Feel free to contact us for questions, issues or feedback.

Best Regards,

Jon