Pregunta

When I executed the command update-database an getting the following error:

Update-Database : Code generated using the T4 templates for Database First and Model First development may not work correctly if used in Code First mode. To continue using Database First or Model First ensure that the Entity Framework connection string is specified in the config file of executing application.

To use these classes, that were generated from Database First or Model First, with Code First add any additional configuration using attributes or the DbModelBuilder API and then remove the code that throws this exception. At line:1 char:16 + Update-Database <<<< -verbose + CategoryInfo : NotSpecified: (:) [Update-Database], UnintentionalCodeFirstException + FullyQualifiedErrorId : System.Data.Entity.Infrastructure.UnintentionalCodeFirstException,System.Data.Entity.Migrations.UpdateDatabaseCommand

What I'm doing wrong??

¿Fue útil?

Solución

I think the problem is that you are using a Code Generation Template to get you Entity classes from the model. If you want to use EntityFramework.Migrations, you should change your approach to Code First. What you can do is copy all the Entity Classes generated from the T4 template on another folder, delete the model (EDMX) and the other T4 files, and then add the Entity Classes that you backed up before again to your project.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top