Tip for working with embedded Ent. Framework models with Beta3

Because of a bug in the way the schema files are created, the behavior for embedding the model into your assembly and the impact on using that assembly in other projects is a little funky. This will change with the next iteration of the EF that we will see as it has been fixed.

In the meantime, there are two things to keep in mind.

1) When you compile, even if you want the files embedded, choose the Copy to Output Directory option for Metadata Artifact Processing, then build, then change the option to Embed in Output Assembly.

2) If you make a change to the model and rebuild, after it is already being referenced by another project, you may or may not get the changes reflected in the assembly and therefore the client project will still fail. In most cases, doing the 2-step build will do the trick. In other cases, it is necessary to go into the bin directory of the model’s project and delete all of the schema files (csdl, msl & ssdl) or just delete every thing in there, then do the two step rebuild again.

As I’ve been working on samples over and over and over, and adjusting my model, I’ve gotten into the habit of doing this.

One easy red-flag that you need to do this is if you get an error message complaining about C-side vs. O-side. That means that something in the CSDL is different than the classes (O=Objects) that were codegen’d. So you while the assembly does have the updated classes, it doesn’t have the updated model.

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.