views:

42

answers:

1

Hello.

Does anyone know how could I get the data model class updated after I make some custom changes in the .dbml file.

I tried to manually mark some fields nullable in the .dbml, but changes are not visible in the code, no matter how many times I rebuild. I even tried to edit .dbml(xml) in an external tool, and then save, but no use.

edit<< Here's the snippet for shaunmartin...

<Table Name="dbo.Clients_Banks" Member="Clients_Banks">
<Type Name="Clients_Banks">
  <Column Name="ID" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
  <Column Name="FKClients" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
  <Column Name="BankName" Type="System.String" DbType="NVarChar(100) NOT NULL" CanBeNull="false" />
  <Column Name="BankAccountNo" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" />
  <Column Name="Party" Type="System.String" DbType="NVarChar(50)" CanBeNull="true" />
  <Column Name="ClientAccountNo" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" />
  <Column Name="Active" Type="System.Boolean" DbType="Bit NOT NULL" CanBeNull="false" />
  <Column Name="NonResidentialAccount" Type="System.Boolean" CanBeNull="false" />
  <Column Name="Swift" Type="System.String" CanBeNull="true" />
  <Column Name="Iban" Type="System.String" CanBeNull="true" />
  <Association Name="Clients_Clients_Banks" Member="Clients" ThisKey="FKClients" OtherKey="ID" Type="Clients" IsForeignKey="true" />
</Type>

I just changed CanBeNull property from false, to true, for the last two members (Iban and Swift). Nothing major, but I need this to be done.

A: 

Ok, I am assuming you have already set Nullable to True in the Properties window of the Visual Studio when you have the Swift or Iban field selected in the entity designer, and then you have saved to regenerate the .Designer.cs file. If so (it sounds like you're doing this...), this is what you should be seeing:

With Nullable set to True:

<Column Member="Swift" Storage="_Swift" Type="System.String" CanBeNull="true" UpdateCheck="Always" />

Should generate this:

[Column(Storage="_Swift")]
public string Swift
{
...

With Nullable set to False:

<Column Member="Swift" Storage="_Swift" Type="System.String" CanBeNull="false" UpdateCheck="Always" />

Should generate this:

[Column(Storage="_Swift", CanBeNull=false)]
public string Swift
{
...

So as you can see, String is nullable by default, so there is no need for a CanBeNull property in the Column attribute when Nullable is set to True.

Anyway, if the above doesn't provide any more clues, you may need to provide a snippet of your generated code (as I mentioned in a comment on your question). Hope this helps.

shaunmartin