amiram Posts 13
|
Hi, I found a naming bug in the associations naming. If you have to foreign keys in a table from a single table, one of them is named with "By" which is very good comparing to VS that uses only a number suffix. But, imagine the following scenario: 1. City table - ID int PK, CityName nvarchar. 2. Person table - ID in PK, PersonName nvarchar, HomeCityID FK from City.ID. Now Person gets a property named City, and City Gets a property named Persons (EntitySet). Now go back to the database, delete column Person.HomeCity and add column Person.WorkCity with FK from City.ID. Update the dbml again. You should get the same properties - Person.City and City.Persons because HomeCity column does not exist anymore, but this is the output:
Updating Linq-to-SQL classes from database schema... Removed member HomeCity from class Person corresponding to removed field dbo.Person.HomeCity Added member WorkCity to Person (dbo.Person.WorkCity) Added association CityByWorkCity to Person corresponding to foreign key constraint FK_Person_City. The underlying foreign key for association City_Person on table Person is no longer in the database. Dropping association. Added association PersonsByWorkCity to City corresponding to foreign key constraint FK_Person_City. The underlying foreign key for association City_Person on table City is no longer in the database. Dropping association. Completed updating the Linq-to-SQL classes from the database.
As you can see, the tool add the new WorkCity association before deleting the deleted HomeCity association, so you get unnecessary long names Person.CityByWorkCity and City.PersonsByWorkCity. This happened to me many times in my main project. Obviously, a temporary solution is to delete one of the tables from the dbml diagram and update again.
Thanks
|