New Posts New Posts RSS Feed: Code First Migration
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Code First Migration

 Post Reply Post Reply
Author
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Topic: Code First Migration
    Posted: 12-Sep-2012 at 8:13pm
Hi Silvio,

Disregard my last reply, I already fixed the issue.
But with the orignial post, just update me when you're done.

Thanks,
Von
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2012 at 6:57pm
Hi Silvio,

What I mean to say is the Model I'm compiling now with those errors is not the same as the one i send or the one you send, this are separate set of tables, basically another model.

Thanks,
Von
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2012 at 9:03am
Von,
While I was able to compile and enable Migrations in the sample I sent you, it's just for your reference.
I moved the Entity classes around to keep them organized.
Basically the change is that I removed the ForeignKey tags and added a few necessage navigation using fluent API.
Also, be sure to update the connectionString.
Silvio.
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2012 at 4:20am
Hi,

Ok thanks..
Just keep me posted on how it goes.
Btw, did you already encountered some errors like the following:

1st Error:

Error 7 An error occurred during metadata generation and a metadata file could not be created.  Error: Unable to find the requested .Net Framework Data Provider.  It may not be installed. iRely.TankManagement.Model

2nd Error:

Error 7 An error occurred during metadata generation and a metadata file could not be created.  Error: Sequence contains more than one element iRely.TankManagement.Model

This happens when I compile the model (This is not the same model as the first one I send)



Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 11-Sep-2012 at 1:53pm
Hi Von,
 
I isolated the issue to the [ForeignKey].
I'm still working on determining if this is an EF or DevForce issue.
In the meantime, in order to get you going, you should remove all [ForeignKey] tags from your code.
Note that for your code in particular most of them are redundant because the PK~FK is following naming convention, but you still have a few relations you should either change the property names to follow convention or use fluent API.
 
I'm attaching your sample with the changes I made, so you can get a headstart: uploads/892/iRely.Model.zip
 
Regards,
   Silvio.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 11-Sep-2012 at 9:14am
Hi Von,
 
I'm still investigating and will keep you posted.
 
Silvio.
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 10-Sep-2012 at 6:36pm
Hi Guys,

Just want to follow up this.. 

Thanks,
Von
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2012 at 6:26pm
This is the link of my project:

The Database Backup is inside the folder Backup


Edited by Vonzkie - 06-Sep-2012 at 6:26pm
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2012 at 5:26pm
Hi,

Actually, that's what I did, I select the Project where the DBContext resides.

Btw., the error shown above happened when I used 4.3.1 version of EF4.
Now, I use 4.3.0 and the error didn't show but this is the new error:

PM> Enable-Migrations -Force
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EdmEntityType entityType, EdmModel model)
   at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntities(EdmModel model)
   at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
   at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
   at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer)
   at System.Data.Entity.Migrations.Extensions.DbContextExtensions.<>c__DisplayClass1.<GetModel>b__0(XmlWriter w)
   at System.Data.Entity.Migrations.Extensions.DbContextExtensions.GetModel(Action`1 writeXml)
   at System.Data.Entity.Migrations.Extensions.DbContextExtensions.GetModel(DbContext context)
   at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext)
   at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
   at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
Object reference not set to an instance of an object.

PM> Add-Migration Sample -StartupProjectName "iRely.Model"
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EdmEntityType entityType, EdmModel model)
   at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntities(EdmModel model)
   at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
   at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
   at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer)
   at System.Data.Entity.Migrations.Extensions.DbContextExtensions.<>c__DisplayClass1.<GetModel>b__0(XmlWriter w)
   at System.Data.Entity.Migrations.Extensions.DbContextExtensions.GetModel(Action`1 writeXml)
   at System.Data.Entity.Migrations.Extensions.DbContextExtensions.GetModel(DbContext context)
   at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext)
   at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
   at System.Data.Entity.Migrations.Design.ToolingFacade.GetPendingMigrationsRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
Object reference not set to an instance of an object.




Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2012 at 3:27am
Hi,

In the console, you might need to specify in the Default Project combo the Assembly where you DBContext is located.
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2012 at 1:12am
Btw., I have an existing database here, I do not create my Database using code first.

Here are my errors:

PM> Enable-Migrations -Force
No classes deriving from DbContext found in the current project.
Edit the generated Configuration class to specify the context to enable migrations for.
No migrations configuration type was found in the assembly ' MyDomain'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).


PM> Add-Migration Sample -StartupProjectName "MyDomain"
No migrations configuration type was found in the assembly 'MyDomain'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).

Note: I have a custom DBContext in my project
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2012 at 12:20am
Hi,

Do you have a working example of a Devforce Code First project that uses the Migration Feature of Entity Framework 4.3?
Cause I'm having hard time trying to do what is instructed on this article:

I have some errors while executing NuGet commands and I don't know if this is not compatible with Devforce.

Thanks,
Von
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down