Oct 25

Synchronising Code First Entity Framework database with existing database

Suppose you have an existing Entity Framework database in production and you’ve made changes to the model in your C# project. Of course you have messed up / lost your migrations files. What to do?

– delete the _MigrationHistory table from the database

– delete the Migrations folder from you solution (you might want to keep a backup of the Configurations.cs file is you’ve made changes to that e.g. Seed)

– in the package manager console type:

  1. enable-migrations
  2. add-migration initialcreate -ignorechanges
  3. update-database

Your all set!

Sep 11

Breeze: Navigation property is not present in client side, while the Metadata has the property defined.

I’m using breeze and WebApi 2. A navigation property is serialized OK, but is not present on the client side.

Solution: in OnModelCreating of the datacontect set the modelbuilder:

 

protected override void OnModelCreating(DbModelBuilder modelBuilder)

{

modelBuilder.Entity<MeetingSessionPoco>()

.HasRequired<MeetingSessionStatusPoco>(m => m.Status);

 

 

Sep 09

Software for design buros

  • create projects
  • create tasks
  • upload large files (multiple gigabytes)
  • create tenders (RFP Request For Proposal)
  • Invite suppliers to projects
  • your suppliers can communicate with your customers via design-traffic, so your customers won’t know that you subcontracted the order

http://www.design-traffic.com

Aug 30

SOLVED: Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.

After making some (of in fact a lot of) changes to my persistent classes I get the error: Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.

I’m using Entity Framework 6, code first and automatic migrations.

How did I solve this:

– run in the package manager console : update-database -verbose -sourcemigration $initialdatabase

Now you can see what is causing the migration to fail. In my case it was changing a one-many relationship to a many-to-many using a extra (explicit) linking table.

Remark: often the issue is with foreignkey  and relationships. Since you perhaps try to modify the relationships, it could be necessary to modify of delete the related data, so SQL server can delete and recreate references on empty tables