All posts by Julie

Installing Visual Studio 2010 RC from a Virtual DVD?

I got bit when installing the VS2010 RC and it cost me a few hours of aggravation. Here’s why.

I use Daemon Tools to mount ISOs to a virtual DVD. I have a Windows 7 machine and am using a new installation of Daemon. By default, Daemon’s auto-mount feature is turned off. I didn’t realize this.

During the installation, the installer needs to reboot. When it rebooted, it didn’t find the DVD and I scrambled to re-attach the ISO file while the installer was attempting to continue setup.

I thought I got it covered, but in the end I had the following error:

rcinstall

What a slap in the face. No Entity Framework tools out of everything in VS that could have been left out! LOL. Well, I do need those.

I tried repairing the installation two times but still the tools did not install.

I finally decided to just uninstall and reinstall but this time I would be smart and burn the darned DVD.

Wouldn’t you know, my brand new DVD writer wasn’t being recognized.

So as a last resort, I used WinRAR to unzipped the ISO file onto my hard drive and I was then able to install directly from the files.

The installation went perfectly. And because I had uninstalled VS2010 but not .NET 4, the reboot was unnecessary.

Since then I have heard from many people that they had no installation problems when using Virtual CloneDrive.

RIA Services in VS2010 Beta 2 and a Debug problem caused by Intellitrace

I had a problem that stopped me in my tracks for two days.

A RIA Services/Silverlight solution which I had created from the Silverlight Business App solution template, was crashing.

Specifically…

In VS2010 Beta 2, using the web development server, I was able to run the app by right clicking on the host web page and choosing View in Browser.

But any time I tried to run it by debugging (F5), I got the old somethingorother not loaded error. That’s the error the domain context on the client side throws when it tries to load data from the service but no data comes back.

After lots of digging, I concluded that in debug mode the client app was unable to find the service.

I won’t go through the two days of hairpulling, but in the end it turned out that the cause of my problem was a known issue with VS2010’s Intellitrace.

It may have been known, but it was not documented anywhere discoverable.

Wilco Bauwer (another great community person who I seem to have forgotten was sucked up by Microsoft at some point – I’m doing this a lot lately…can’t keep track ) was dragged into the thread by Jeff Handley (another silverlight guru at MS,  who had been valiant in trying to help me). Wilco suggested turning off Intellitrace and voila, two days of misery disappeared.

Using the Beta 2 EF POCO Template with VS2010 RC

Update: After realizing that we still want access to it, the team has made the Beta 2 file available again. You can get it from their original blog post, not from the Visual Studio Gallery links but look for a zip file at the bottom of the post.

But there’s more! While I had managed to figure out one big difference (TemplateFileManager name changed) between the old include file and the new include file it wasn’t enough. which is why after a few hours I gave up and went back to the old include file. But Nikola Malovic figured out the second piece which was how to replace the WriteFiles method which is no longer there! Check out his blog post for the super secret trick!

————————————————–

Entity Framework’s T4 templates all have a dependency on a file that includes additional specialized methods.

If you look at the top of the templates (ENtityObject, POCO or Self-Tracking Entiteis) there is a pointer to a ttinclude file.

<#@ include file="EF.Utility.CS.ttinclude"#>

That file, however, changed after Beta 2. The new templates (EntityObject and STE’s both included in VS2010) work wtih the new version of this file. But the POCO template that was released in December doesn’t.

However, I have a trick to have your cake and eat it too until the new POCO template comes along.

This is just a temporary workaround until a new set of templates hits the airwaves. 🙂

The ttinclude files live here:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes

The new one has a file date of Jan 6, 1010.

You can grab the ttinclude file from Beta 2 and rename it. I’ve renamed mind:

EF.B2.Utility.CS.ttinclude

The file date on that one is Sept 15, 2009.

Then copy it into the Includes folder with the new includes.

Now when you create a new POCO template, you’ll first get error message about TemplateFileManager not existing. In the new include, that’s been renamed to EntityFrameworkTemplateFIleManager. But that’s not hte only change. Fixing that name in your template will not help.

Instead,  just change the reference in the template file to read the Beta 2 include :

<#@ include file="EF.B2.Utility.CS.ttinclude"#>

Then the POCO template will use the Beta 2 version of the include and you can go on your merry way.

Thanks to Dane Morgridge for sending me the VSIX file from the Beta 2 POCO since I had installed directly rather than downloading it to my computer.

Video and Q&As from my Top 10 Treats in EF4 WebCast

The video from my webcast, Top 10 Treats in Entity Framework 4 is available on Oreilly’s website: http://www.oreillynet.com/pub/e/1517.

I just discovered that WebEx saved the chat window from my O’Reilly webcast last month. So I thought I would pick out the quesitons and answer them here although I did answer some of them at the end of the webcast:

Q address NOT Address??

Someone noticed that an entity was named address. The pluralization support in the VS2010 EDM Designer does not fix up bad capitalization from the database which this was meant to highlight. Another viewer replied: it’s address and not Address because the original table was with a lower case ‘a’. VS2010 supports pluralization, but doesn’t change capitalization

Q These classes are not POCO, correct? What do I have to do to have POCO and generate db schema?

In the early part of the demo I was wroking with the default EntityObjects. To use POCO classes to generate db schema you’ll want to skip the model and use the Code-Only support that is part of the EF Feature CTP: Updated Feature CTP Walkthrough- Code Only for Entity Framework

This is awesome. We will all forgot how to sql.
Not a question, but a funny comment I wanted to share.

Q What about update database from model?

Update database from model has been supported sine the first version of EF. It will bring in new tables and new properties in tables but it will not modify property types. Be aware that any changes made manually to the SSDL get overwritten during this process.

Q. How much control does the developer have over the generated SQL DDL?
I answered this one at the end of the webcast. There is a T4 template that drives the DDL generation so that’s customizable.

This thing needs a pause button! LOL
Another funny comment I thought I would share. Yeah it is tough doing these webcasts that have a time limit! 🙂

Q. can you control lazy loading on a per entity level?
I happened to answer this question as I was talking about lazy loading and the person who asked then said: “ah thanks … ok, so per context only.”

Q. How easy is it to mock entities for nUnit or xUnit testing?

The new IObjectSet interface makes it totally possible to mock entities now. Many people have written blog posts about this. Here’s mine: http://thedatafarm.wpengine.com/blog/data-access/agile-entity-framework-4-repository-part-5-iobjectset/

Q: I heard something about "model functions" or "schema functions", implying I can do calculations for fields OR create views over entities in the EDM / .edmx file. Is this true?
Yes. Check out http://thedatafarm.wpengine.com/blog/data-access/ef4-model-defined-functions-level-1-amp-2/

Q: how does Oracle support compare? Is it as functionally complete? Is it as stable/bug free?

Oracle providers are available from DevArt and Data Direct. As far as I know they are both very solid. Functionally complete? Dunno.

LINK to EF POCO Adapter for EF1: code.msdn.microsoft.com/EFPocoAdapter

WCF Data Services and EF POCOs that are in their own Assembly

I hit my head against a wall for a while today when I was trying to create a data service using my EF POCOs. I have my model & context in one assembly and my generated POCO entities in another.

When I ran the service (I had exposed all EntitySets for AllRead), I got the mysterious error:

The server encountered an error processing the request. See server logs for more details.

Even with config.UseVerboseErrors = true; in my service, the message did not change.

I finally saw the real problem first in Intellitrace (I’m using VS2010 and .NET 4.0) and then by setting the service behavior’s IncludeExceptionDetailInFaults to true.

This is what the detailed exception looks like:

The server encountered an error processing the request. The exception message is ‘Value cannot be null. Parameter name: key’. See server logs for more details. The exception stack trace is:

at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Collections.Generic.Dictionary`2.FindEntry(TKey key) at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary`2 knownTypes, IDictionary`2 childTypes, IDictionary`2 entitySets) at System.Data.Services.Providers.BaseServiceProvider.PopulateMetadata() at System.Data.Services.DataService`1.CreateProvider() at System.Data.Services.DataService`1.EnsureProviderAndConfigForRequest() at System.Data.Services.DataService`1.HandleRequest() at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet

Key in here for me are “PopulateMetadata” and argument is null.

Looks like we can’t read the metadata, i.e. the CSDL, MSL and/or SSDL files. I’ve got he connection string in web.config so that ‘s not it.

With this info in hand, I found this forum post which clarified the issue: Fail to work with POCO ModelContainer which entities are located in

I neede to force the metadata to load into the application process. I have a handy trick for this which is simpler than the one suggested in the forum.

I blogged about it in 2008: Quick Trick for forcing MetadataWorkspace ItemCollections to load.

So, I added this override to the data service:

     protected override BAPOCOs CreateDataSource()
     {
       var context = new BAPOCOs();
       var tracestring = context.CreateQuery<Contact>("BAPOCOs.Contacts").ToTraceString();
       return context;
     }

Note that calling ToTraceString does not cause a command to be executed on the server.

And my service was back in working condition, however…

There is one thing I’m not happy with. I originally had a test in there to see if the metadata was already loaded. If so, then no need to call ToTraceString. The metadata is supposed to remain in teh app process so after the first hit, I should be skipping the ToTraceString code. However, it was being hit every time and if I forced it to skip, then I was back to the original error.

This seems like an expensive waste of resources and if that’s the case, I’m doing it on EVERY call, I’d rather use the more complex code which explicitly loads the MDW rather than my little trick which is not a big deal if I’m only doing it once. The upside is that this is essentially an Entity SQL query and by default ESQL queries are cached and do not need to be recompiled. So perhaps it’s not so bad. Either way, I’d like to get this solution to a more satisfactory state.

I have asked about this in the above mentioned forum thread.  And will add to this blog post when I get more info.

Vermont IT Jobs: Java Developers at the fast growing Dealer.com

Dealer.com is one of Vermont’s great IT success stories and a very cool place to work.

They are looking to fill a few Java developer positions and are also looking for tech leads. There are some great opportunities for the right people.

Here are the specific positions:

Java Developer:

http://jobs-dealer.icims.com/jobs/1157/job

Senior Java Developer:

http://jobs-dealer.icims.com/jobs/1156/job

Technical Lead:

http://jobs-dealer.icims.com/jobs/1155/job

There are also about 20 other positions open at Dealer.com.

Vermont IT Jobs: (Colorado or telecommute) Sr .NET Developer

Sr. Software Developer position

Meeting Sciences, Inc. is looking for a Sr. Software Developer interested in working on exciting new, and highly unique, solutions in the areas of communication,  collaboration and business intelligence. Deployed as a SaaS (utilizing cloud computing), our solutions are implemented using state‐of‐the art development tools and Agile development methodologies.

We are a unique company in that the highly successful consulting side of our business has been operating globally for 15 years with clients such as Oracle, Cisco, ING, American Express, GE, ExxonMobil, Leo Burnett, Ralph Lauren, and HP, to name just a few, but the software development side of our business is “early‐stage.” Meeting Sciences’ primary product offering on a go‐forward basis is a unique – and already in demand – software product currently under development (targeted for FCS in Q2/2010). The person who fills this position will be joining a small but highly skilled and experienced group of software developers located primarily in Colorado, but with team members located across the country.

The Sr. Software Developer position can be full or part‐time, however currently all positions are 1099 and require a minimum commitment of 20 hours per week. All positions earn equity. Full‐time positions will convert to W‐2 in Q2/2010. Currently we work in a virtual environment, so you must have an environment at home suitable to productive work. All necessary software development tools will be provided by Meeting Sciences.

Requirements
 5+ yr. professional development experience
 Ability to work independently with limited supervision
 Excellent team member and communication skills, able to work effectively in a highly
collaborative virtual environment.
 Proven ability to deliver designs and implementation at module level that meet requirements.
 References

Mandatory experience
 .Net 3.5
 C# 3.0
 OO analysis and design
 Unit testing framework
 Agile development

Desired skills (must possess one or more)
 WCF web services
 ASP.Net server‐side development and large scale deployment
 Silverlight 3
 Windows Services implementation
 SQL‐Server
 LINQ
 SharePoint solution development

If interested and qualified, please send your resume or CV and a cover letter to Russ Panneton, managing
Software Engineer at rpanneton@meetingsciences.com

Passing around an ObjectContext: by value or reference?

<Refresher>

When you pass parameters in VB, you use the ByVal and ByRef keyworks. The default in VB is ByRef with a nuance (see ByRef Parameters Passed by Value)  In C#, no keyword means by value and alternatively, you use the ref keyword to pass a reference.

The key difference is that when you pass a variable by value , you are just passing a copy. The originating variable cannot be replaced.

When passing by reference, you are working with the actual variable and can replace it.

The part that frequently evades developers is that if the value is a reference type (i.e. does not contain it’s values directly compared to, for example, an int which does) you can modify those related values whether you pass by reference or by value.

</Refresher>

Now let’s look at this with respect to an ObjectContext being passed as a parameter. An ObjectContext has it’s own values but also has references to other values (e.g. the ObjectStateEntry types that it maintains to keep track of entities).

Whether you pass the context by value or reference, the entities that the context is tracking will be impacted when you execute queries or call SaveChanges with the context.

When passing it by value you won’t replace the context, e.g, passedinContext=new MyEntities() won’t affect the originating context.

When passing it by ref, you CAN replace the context e.g., passedinContext=new MyEntities() will reinstantiate the originating context. And if you replace the context, you will lose ALL of the state information for the currently tracked entities. Those entities will be orphaned – just sitting in memory with nobody tracking them and if you do reattach them to the new instance of the context, they will all be unchanged.

That’s a big problem.

So unless you are trying to achieve some specific behavior, you should definitely pass byval. In fact you should define your method signature that takes the parameter to ensure that you are passing by value.

O’Reilly Webcast tomorrow, Jan 27, Top 10 Treats in EF4

Tomorrow at 10am PST/1pm EST, I’ll be presenting a live web cast for O’Reilly Media called the Top 10 Treats in Entity Framework 4. The web cast is one hour (including intro and questions). Short & sweet.

You can register at http://www.oreillynet.com/pub/e/1517.

The webcast will be recorded and available at the same link approximately one week later.

Tour the Top 10 Treats in Entity Framework 4

DateWednesday, January 27, 2010

Time 10am PT, San Francisco
6pm – London | 1pm – New York | Thu, Jan 28th at 5am – Sydney | Thu, Jan 28th at 3am – Tokyo | Thu, Jan 28th at 2am – Beijing | 10:30pm – Mumbai

Presented by: Julia Lerman

Duration: Approximately 60 minutes.

Cost: Free

Visual Studio 2010 and .NET 4.0 bring us a new version of ADO.NET Entity Framework, called Entity Framework 4. From the designer, to the APIs to entire new feature sets to support agile development, even former EF skeptics are getting excited about this version. There is a lot to see. In this one hour webcast, Julie Lerman, who is currently working on the 2nd edition of Programming Entity Framework, will highlight the ten most significant changes to the Entity Framework.

About Julia Lerman

Julia Lerman is the leading independent authority on the Entity Framework and has been using and teaching the technology since its inception two years ago. She is well known in the .NET community as a Microsoft MVP, ASPInsider and INETA Speaker. She is a prolific blogger, a frequent presenter at technical conferences around the world, including DevConnections and TechEd and she writes articles for many well–known technical publications.

Julia lives in Vermont where she runs the Vermont.NET User Group, was a founding board member of the Vermont Software Developers Alliance, and is a member of the Champlain College Software Engineering Advisory Board. You can read her blog at www.thedatafarm.com/blog.

Vermont IT Jobs: 4 programming jobs listed in this week’s Seven Days

  1. Norwich University: Web App Developer with FLash/Flex experience
  2. ARD: Software Developer
  3. UVM: Web Programmer in Continuing Ed – HTML, PHP, MySQL and more
  4. PKC: Sr. .NET Desktop Software Engineer – C# & WPF required;  WCF, XML, SQL, version control and CSLA helpful

Plus two support jobs:

  1. Pcc.com is looking for a Software Support Specialist
  2. Middlebury College: Sr. Technology Specialiast (aka Help Desk)

See sevendaysvt.com/classifieds for more details.