Thursday, December 3, 2009

LINQ to SQL Entity Base - Version 1.2 Beta

Hi everyone,

I've released a beta of the LINQ 2 SQL Entity Base - included in it is the following changes since the V1.1 final:

  • Bug Fix: If the entity's state is "New", LINQ to SQL Tries to attach an FK references as "New" as well - even though this was unintended. Fixed it so it does not try and insert FK referenced entities when adding a new object. Thanks Mark & Stephan for finding/fixing the issue
  • Bug Fix: If the onModifyKeepOriginal parameter on SetAsChangeTrackingRoot() is set to true and an object is detached from a collection (i.e. x.remove(y)), the object was not being attached properly to the data context when SynchroniseWithDataContext() was called, causing an error to be thrown. Thanks Yaki for finding the issue!
  • Bug Fix: When EntityState == CanceNew, don't change to EntityState == Deleted when SetAsDeleteOnSubmit is called.
  • Feature: Added ShallowCompare Method, which compares the properties of two entities and returns true if all the properties match (compare LINQ to SQL ColumnAttribute properties only).
  • Feature: If the onModifyKeepOriginal parameter on SetAsChangeTrackingRoot() is set to true, and an object is modified (i.e. EntityState == Modified) and then modified again in a way which set's it back to be the same as property values as it's original state, the entity will now have it's EntityState set to back Original (instead of remaining as EntityState == "Modified").

It can be downloaded here:

http://linq2sqleb.codeplex.com

Cheers

Matt.

Tuesday, October 27, 2009

Address Attribute Length Fun in CRM 4.0

When you extend the length of Address attribute on a Contact or Account, this does not actually extend the length of the attribute in the database auto-magically only the length of the data that can be entered on the UI.

The address details are not stored agains the customer, they are stored in a seperate entity called "Address".

In order to extend the address you need to update the "Address" attribute too.

See this KB for more info:

http://support.microsoft.com/kb/973029

Data Migration Manager Troubles with CRM 4.0

Today I spent quite a lot of time trying to figure out why the data migration manager would not let me sign in.

I'd just installed Rollup Pack 7, and noticed that there was no Data Migration Manager Update available in Rollup Pack 7, so I installed Rollup Pack 6's version of this update.

Everytime I tried to login, it would complain that ...

"You must have the System Administrator Security Role to use this Tool".

I was puzzled, I checked multiple times to make sure that the user I put in during the install was correct, I searched the web - but this error had not be reported anywhere by anyone.

Finally I decided to remove the Rollup Pack 6 update (only the update) for the Data Migration Manager, and to my surprise this worked! Infact I was even more surprised to find that it did not complain that there were updates available for it (which it usually does...).

Anyway, I re-installed the Data Migration Manager Rollup 6 Update and it now works.

So the fix is to Re-install if you get this error message.

[UPDATE] Came into work this morning, and a member of my team had exactly the same problem on a completely different server, Wonder if there's a Data Migration Manager Rollup-7 that hasn't been upload to the MS Download Site yet?

[UPDATE2] There's a Rollup Pack 7 installer for the Data Migration Manager Now, however haven't tried it yet to see if it works personally, but apparently it does.

Friday, September 4, 2009

Default Organization For User is incorrect in CRM 4.0

Occasionally you come across the situation where the default organization has been changed and some of the users are still mapped with the default to the old database. This is quite annoying and can actually point your custom aspx pages to the wrong organization.

To fix this issue, I've written a SQL Server script which basically does the following:

  1. Finds the specified organization in the MSCRM_CONFIG database (the one that you want to be the default)
  2. Finds the specified user ( which has the incorrect default database ) in the organization database which is intended to be the default (Based on '<domain>\<username>')
  3. Finds the user details in the MSCRM_CONFIG database from the specified user found in the organization database
  4. Updates the user record in the MSCRM_CONFIG database to have the specified default organization set.

Notes on running the script:

  1. Backup your MSCRM_CONFIG database first! This is unsupported by Microsoft S and Me!
  2. Set the Domain\Username & Organization Name in the section titled 'PLEASE FILL IN THE FOLLOWING'
    1. The @UserDomainName is the same as found the DomainName box in the User CRM Screen
    2. The @DefaultOrganization should be the name of the organization as shown in the deployment manager
  3. The script is designed to be executed in the context of the organization database which you want to be the default for the specified user, please make sure that this is set to the correct database before running
    1. i.e. you can do this by using the 'Use <databasename>' command in SQL first before executing the script.


DECLARE @DefaultOrganization AS
VARCHAR(100)

DECLARE @DefaultOrganizationId AS
VARCHAR(100)

DECLARE @UserDomainName AS
VARCHAR(100)

DECLARE @CRMUserId AS
VARCHAR(100)

DECLARE @UserId AS
VARCHAR(100)


-----------------------------------

-- PLEASE FILL IN THE FOLLOWING ---

-----------------------------------

SET @UserDomainName = '<domain>\<username>'

SET @DefaultOrganization = '<organizationname>'

-----------------------------------

-----------------------------------


-- NOTE: Don't touch the below statements

SELECT @DefaultOrganizationId = id FROM MSCRM_CONFIG..organization WHERE UniqueName = @DefaultOrganization

IF @DefaultOrganizationId is not null

BEGIN

SELECT @CRMUserId = systemuserid FROM systemuserbase WHERE domainname = @UserDomainName

IF @CRMUserId is not null

BEGIN

SELECT @UserId = userid FROM MSCRM_CONFIG..systemuserorganizations WHERE crmuserid = @CRMUserId

IF @UserId is not null

BEGIN

SELECT 'BEFORE', * FROM MSCRM_CONFIG..systemuser WHERE id = @UserId

UPDATE MSCRM_CONFIG..systemuser

SET defaultorganizationid = @DefaultOrganizationId

WHERE id = @UserId

SELECT 'AFTER', * FROM MSCRM_CONFIG..systemuser WHERE id = @UserId

END

ELSE

BEGIN

PRINT 'The User was Not Found in the Organization - Please check'

END

END

ELSE

BEGIN

PRINT 'The User was Not Found in CRM - Please check'

END

END

ELSE

BEGIN

PRINT 'Default Organization Not Found - Please check'

END



Tuesday, September 1, 2009

Run as Different User in Windows 7

In windows XP, when you wanted to run as a different user you could by right-clicking and selecting "Run As", in Windows Vista this was missing – although you could use the RunAs.exe in command line to kick off an application as a different user – it was really annoying and painful to do.

Now in Windows 7, Run As is back!

To run as a different user, simply hold down shift and right click on an icon to get the "Run as different User" option.

Very useful in MS CRM for testing our roles for different user.

Matt.


 

Friday, August 28, 2009

Access denied to something? – try changing your password


 

One thing that I've found time and time again with Windows authentication is that even though you have access to something and your password is not expired – you may still received the "access denied" type response from different applications/services.

At first you think it's some kind of issue with permissions, you try rebooting etc... But nothing works.

In these circumstances, if you have noticed that you are being reminded to change your password when you log onto the windows server/workstation – then changing your password may be the key!

It seems that although technically your account on the domain hasn't expired - because it's due to expire this sometimes seems to be interpreted as the same thing (i.e. it considers your account expired). Perhaps the underlying integrated security authentication that goes on behind the scenes doesn't always deal with this situation properly, and just rejects by default.

Anyway, try changing your password and see if that helps!

Matt.

Tuesday, July 14, 2009

Version 1.1 Final of LINQ to SQL Entity Base Released

Hi everyone,

I've released the latest version of the LINQ to SQL Entity Base. If you are unfamiliar with it, it allows you to have change tracking without having to have the DataContext object within scope.

Here's the changes since Version 1.0

Improvement: Implemented caching for reflected properties which should significantly speed up creation of entity instances. Thanks Johannes!

Improvement: If you delete an entity while it is in the new state (and therefore has not been submitted to the database yet), the entity will now be removed from the scope of the entity tree during the call SyncronisationWithDataContext(), and as there are no references to the entity anymore it will be garbage collected. Before this change, the object would still hang around.

Bug Fix: Issue where setting a value FK value via object reference did not result in entity being flagged as modified unless you modified another property on that entity as well.


Anyway, head on over to codeplex to check it out.

Cheers

Matt.