This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a property in an entity that I want to make unique. It is defined as a nvarchar(120) in the database. When I set the Validate Unique property to true and try to update the database from the designer, I get an error saying "The following differences were detected but cannot be applied automatically. Warehouse: Apply unique constraint to Name" As a test, I was able to manually create an index on this column using SQL Server Management Studio. Why won't Lightspeed? Thanks |
|
|
Just prioritisation. We had feedback that customers wanted unique constraints in the database to be reflected in the model, but we hadn't had the same feedback about going the other way, so for reasons of time we put it on hold. I've now implemented adding unique constraints and it will be in the 4 May nightly build. Please let us know if you run into any problems or errors (and let us know which database you're using). Removing unique constraints is a bit trickier on some databases and remains on hold for now: let us know if this is a significant issue for you. |
|
|
I'm using SQL Server 2005 on my system and we're planning on SQL Server 2008 on the test system. I was able to create the constraint on my system after installing the new version. Don't quite yet have the test system up and running so don't know about 2008. Thanks |
|
|
Oops! When I tried to set the Validate Unique attribute on the Name property in a second table I received an error saying that there was already a constraint named "Name". Why doesn't Lightspeed allow for the same property in two tables being constrained? |
|
|
We weren't sufficiently uniqueifying the constraint name. I have committed a fix which will be in the next nightly build (6 May). Sorry for the inconvenience and thanks for drawing this to our attention. |
|
|
I have migrated my database to SQL Server 2008 and installed the 6/3 build and I have a couple of questions/issues. First, in the designer there is not a provider for SqlServer 2008. Is the 2005 provider ok? I tried to apply Validate Unique to a field and get the following error: Column 'Name' in table 'Vendors' is of a type that is invalid for use as a key column in an index. When I was using SQL Server 2005 we were able to set this property. Is there something different for 2008? Thanks.
|
|
|
Yes, the 2005 provider is fine in the designer. However, if you plan to use SQL Server-specific data types such as spatial types, then you must specify the 2008 provider in your runtime configuration (i.e. your LightSpeedContext settings). The Validate Unique issue probably isn't a 2005/2008 issue but more likely because LightSpeed now tries to convert unique validations to unique keys when updating SQL Server databases. SQL Server doesn't allow you to apply unique keys to TEXT (or (N)VARCHAR(MAX)) columns. (I could be wrong and maybe 2005 did allow this, but anyway.) So I would guess your Name property has no length validation on it. We should probably add some smarts to the designer to not try to translate the unique validation into a unique key when the data type is a blob or string with no length validation. In the meantime, either uncheck the "apply unique constraint to column Name' in the Update Database dialog, or apply a length validation to Name (even a vacuous one like <= 3999). Thanks for alerting us to this. |
|
|
Your guess was right on target. I didn't have a length validation but do now. Thanks! |
|
|
+1 for improving designer error message here. Came across this thread whilst experiencing exact same issue. |
|