none
Could DataContext.CreateDatabase() create the schemas? RRS feed

  • Question

  • I use SqlMetal.exe to generated DataContext for AdventureWorks database, when I try DataContext.CreateDatabase to rebuild the database it throws exceptions like:

    System.Data.SqlClient.SqlException: The specified schema name "Production" either does not exist or you do not have permission to use it.

    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
    System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
    System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    System.Data.Linq.SqlClient.SqlProvider.ExecuteCommand(String command)
    System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.CreateDatabase()
    System.Data.Linq.DataContext.CreateDatabase()

    How can I configure it to auto create the schemas?
    Sunday, August 31, 2008 8:16 AM

All replies

  • CreateDatabase does not recreate the entire SQL database but just the information that was encapsualted into the attributes. This means no stored procedures, triggers, schemas etc.

     

    What you could do is script out the schema in SQL Management Studio and then paste these lines into your application and run them before CreateDatabase using the DataContext ExecuteCommand method.

     

    [)amien

     

    Tuesday, September 2, 2008 5:26 PM
    Moderator
  • Hello Damien!

    I respact that way, DataContext.CreateDatabase will throw an exception "database already exists".


    With look into the code of
    DataContext.CreateDatabase, it looks like it's creating schemas
    (please look into "
    System.Data.Linq.SqlClient.SqlProvider.CreateDatabase", and look for "createSchemaForTableCommand")

    But it does not functions for me, strange... my DataContext is like:

    Code Snippet

    #pragma warning disable 1591
    //------------------------------------------------------------------------------
    // <auto-generated>
    // This code was generated by a tool.
    // Runtime Version:2.0.50727.1434
    //
    // Changes to this file may cause incorrect behavior and will be lost if
    // the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.Linq;
    using System.Data.Linq.Mapping;
    using System.Linq;
    using System.Linq.Expressions;
    using System.Reflection;



    public partial class AdventureWorksTestDatabase : System.Data.Linq.DataContext
    {

    private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertProduction_Product(Production_Product instance);
    partial void UpdateProduction_Product(Production_Product instance);
    partial void DeleteProduction_Product(Production_Product instance);
    partial void InsertProduction_ProductSubcategory(Production_ProductSubcategory instance);
    partial void UpdateProduction_ProductSubcategory(Production_ProductSubcategory instance);
    partial void DeleteProduction_ProductSubcategory(Production_ProductSubcategory instance);
    #endregion

    public AdventureWorksTestDatabase(string connection) :
    base(connection, mappingSource)
    {
    OnCreated();
    }

    public AdventureWorksTestDatabase(System.Data.IDbConnection connection) :
    base(connection, mappingSource)
    {
    OnCreated();
    }

    public AdventureWorksTestDatabase(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
    base(connection, mappingSource)
    {
    OnCreated();
    }

    public AdventureWorksTestDatabase(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
    base(connection, mappingSource)
    {
    OnCreated();
    }

    public System.Data.Linq.Table<Production_Product> Production_Product
    {
    get
    {
    return this.GetTable<Production_Product>();
    }
    }

    public System.Data.Linq.Table<Production_ProductSubcategory> Production_ProductSubcategory
    {
    get
    {
    return this.GetTable<Production_ProductSubcategory>();
    }
    }
    }

    [Table(Name="Production.Product")]
    public partial class Production_Product : INotifyPropertyChanging, INotifyPropertyChanged
    {

    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

    private int _ProductID;

    private string _Name;

    private string _ProductNumber;

    private bool _MakeFlag;

    private bool _FinishedGoodsFlag;

    private string _Color;

    private short _SafetyStockLevel;

    private short _ReorderPoint;

    private decimal _StandardCost;

    private decimal _ListPrice;

    private string _Size;

    private string _SizeUnitMeasureCode;

    private string _WeightUnitMeasureCode;

    private System.Nullable<decimal> _Weight;

    private int _DaysToManufacture;

    private string _ProductLine;

    private string _Class;

    private string _Style;

    private System.Nullable<int> _ProductSubcategoryID;

    private System.DateTime _SellStartDate;

    private System.Nullable<System.DateTime> _SellEndDate;

    private System.Nullable<System.DateTime> _DiscontinuedDate;

    private System.Guid _Rowguid;

    private System.DateTime _ModifiedDate;

    private EntityRef<Production_ProductSubcategory> _Production_ProductSubcategory;

    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnProductIDChanging(int value);
    partial void OnProductIDChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnProductNumberChanging(string value);
    partial void OnProductNumberChanged();
    partial void OnMakeFlagChanging(bool value);
    partial void OnMakeFlagChanged();
    partial void OnFinishedGoodsFlagChanging(bool value);
    partial void OnFinishedGoodsFlagChanged();
    partial void OnColorChanging(string value);
    partial void OnColorChanged();
    partial void OnSafetyStockLevelChanging(short value);
    partial void OnSafetyStockLevelChanged();
    partial void OnReorderPointChanging(short value);
    partial void OnReorderPointChanged();
    partial void OnStandardCostChanging(decimal value);
    partial void OnStandardCostChanged();
    partial void OnListPriceChanging(decimal value);
    partial void OnListPriceChanged();
    partial void OnSizeChanging(string value);
    partial void OnSizeChanged();
    partial void OnSizeUnitMeasureCodeChanging(string value);
    partial void OnSizeUnitMeasureCodeChanged();
    partial void OnWeightUnitMeasureCodeChanging(string value);
    partial void OnWeightUnitMeasureCodeChanged();
    partial void OnWeightChanging(System.Nullable<decimal> value);
    partial void OnWeightChanged();
    partial void OnDaysToManufactureChanging(int value);
    partial void OnDaysToManufactureChanged();
    partial void OnProductLineChanging(string value);
    partial void OnProductLineChanged();
    partial void OnClassChanging(string value);
    partial void OnClassChanged();
    partial void OnStyleChanging(string value);
    partial void OnStyleChanged();
    partial void OnProductSubcategoryIDChanging(System.Nullable<int> value);
    partial void OnProductSubcategoryIDChanged();
    partial void OnSellStartDateChanging(System.DateTime value);
    partial void OnSellStartDateChanged();
    partial void OnSellEndDateChanging(System.Nullable<System.DateTime> value);
    partial void OnSellEndDateChanged();
    partial void OnDiscontinuedDateChanging(System.Nullable<System.DateTime> value);
    partial void OnDiscontinuedDateChanged();
    partial void OnRowguidChanging(System.Guid value);
    partial void OnRowguidChanged();
    partial void OnModifiedDateChanging(System.DateTime value);
    partial void OnModifiedDateChanged();
    #endregion

    public Production_Product()
    {
    this._Production_ProductSubcategory = default(EntityRef<Production_ProductSubcategory>);
    OnCreated();
    }

    [Column(Storage="_ProductID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    public int ProductID
    {
    get
    {
    return this._ProductID;
    }
    set
    {
    if ((this._ProductID != value))
    {
    this.OnProductIDChanging(value);
    this.SendPropertyChanging();
    this._ProductID = value;
    this.SendPropertyChanged("ProductID");
    this.OnProductIDChanged();
    }
    }
    }

    [Column(Storage="_Name", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    public string Name
    {
    get
    {
    return this._Name;
    }
    set
    {
    if ((this._Name != value))
    {
    this.OnNameChanging(value);
    this.SendPropertyChanging();
    this._Name = value;
    this.SendPropertyChanged("Name");
    this.OnNameChanged();
    }
    }
    }

    [Column(Storage="_ProductNumber", DbType="NVarChar(25) NOT NULL", CanBeNull=false)]
    public string ProductNumber
    {
    get
    {
    return this._ProductNumber;
    }
    set
    {
    if ((this._ProductNumber != value))
    {
    this.OnProductNumberChanging(value);
    this.SendPropertyChanging();
    this._ProductNumber = value;
    this.SendPropertyChanged("ProductNumber");
    this.OnProductNumberChanged();
    }
    }
    }

    [Column(Storage="_MakeFlag", DbType="Bit NOT NULL")]
    public bool MakeFlag
    {
    get
    {
    return this._MakeFlag;
    }
    set
    {
    if ((this._MakeFlag != value))
    {
    this.OnMakeFlagChanging(value);
    this.SendPropertyChanging();
    this._MakeFlag = value;
    this.SendPropertyChanged("MakeFlag");
    this.OnMakeFlagChanged();
    }
    }
    }

    [Column(Storage="_FinishedGoodsFlag", DbType="Bit NOT NULL")]
    public bool FinishedGoodsFlag
    {
    get
    {
    return this._FinishedGoodsFlag;
    }
    set
    {
    if ((this._FinishedGoodsFlag != value))
    {
    this.OnFinishedGoodsFlagChanging(value);
    this.SendPropertyChanging();
    this._FinishedGoodsFlag = value;
    this.SendPropertyChanged("FinishedGoodsFlag");
    this.OnFinishedGoodsFlagChanged();
    }
    }
    }

    [Column(Storage="_Color", DbType="NVarChar(15)")]
    public string Color
    {
    get
    {
    return this._Color;
    }
    set
    {
    if ((this._Color != value))
    {
    this.OnColorChanging(value);
    this.SendPropertyChanging();
    this._Color = value;
    this.SendPropertyChanged("Color");
    this.OnColorChanged();
    }
    }
    }

    [Column(Storage="_SafetyStockLevel", DbType="SmallInt NOT NULL")]
    public short SafetyStockLevel
    {
    get
    {
    return this._SafetyStockLevel;
    }
    set
    {
    if ((this._SafetyStockLevel != value))
    {
    this.OnSafetyStockLevelChanging(value);
    this.SendPropertyChanging();
    this._SafetyStockLevel = value;
    this.SendPropertyChanged("SafetyStockLevel");
    this.OnSafetyStockLevelChanged();
    }
    }
    }

    [Column(Storage="_ReorderPoint", DbType="SmallInt NOT NULL")]
    public short ReorderPoint
    {
    get
    {
    return this._ReorderPoint;
    }
    set
    {
    if ((this._ReorderPoint != value))
    {
    this.OnReorderPointChanging(value);
    this.SendPropertyChanging();
    this._ReorderPoint = value;
    this.SendPropertyChanged("ReorderPoint");
    this.OnReorderPointChanged();
    }
    }
    }

    [Column(Storage="_StandardCost", DbType="Money NOT NULL")]
    public decimal StandardCost
    {
    get
    {
    return this._StandardCost;
    }
    set
    {
    if ((this._StandardCost != value))
    {
    this.OnStandardCostChanging(value);
    this.SendPropertyChanging();
    this._StandardCost = value;
    this.SendPropertyChanged("StandardCost");
    this.OnStandardCostChanged();
    }
    }
    }

    [Column(Storage="_ListPrice", DbType="Money NOT NULL")]
    public decimal ListPrice
    {
    get
    {
    return this._ListPrice;
    }
    set
    {
    if ((this._ListPrice != value))
    {
    this.OnListPriceChanging(value);
    this.SendPropertyChanging();
    this._ListPrice = value;
    this.SendPropertyChanged("ListPrice");
    this.OnListPriceChanged();
    }
    }
    }

    [Column(Storage="_Size", DbType="NVarChar(5)")]
    public string Size
    {
    get
    {
    return this._Size;
    }
    set
    {
    if ((this._Size != value))
    {
    this.OnSizeChanging(value);
    this.SendPropertyChanging();
    this._Size = value;
    this.SendPropertyChanged("Size");
    this.OnSizeChanged();
    }
    }
    }

    [Column(Storage="_SizeUnitMeasureCode", DbType="NChar(3)")]
    public string SizeUnitMeasureCode
    {
    get
    {
    return this._SizeUnitMeasureCode;
    }
    set
    {
    if ((this._SizeUnitMeasureCode != value))
    {
    this.OnSizeUnitMeasureCodeChanging(value);
    this.SendPropertyChanging();
    this._SizeUnitMeasureCode = value;
    this.SendPropertyChanged("SizeUnitMeasureCode");
    this.OnSizeUnitMeasureCodeChanged();
    }
    }
    }

    [Column(Storage="_WeightUnitMeasureCode", DbType="NChar(3)")]
    public string WeightUnitMeasureCode
    {
    get
    {
    return this._WeightUnitMeasureCode;
    }
    set
    {
    if ((this._WeightUnitMeasureCode != value))
    {
    this.OnWeightUnitMeasureCodeChanging(value);
    this.SendPropertyChanging();
    this._WeightUnitMeasureCode = value;
    this.SendPropertyChanged("WeightUnitMeasureCode");
    this.OnWeightUnitMeasureCodeChanged();
    }
    }
    }

    [Column(Storage="_Weight", DbType="Decimal(8,2)")]
    public System.Nullable<decimal> Weight
    {
    get
    {
    return this._Weight;
    }
    set
    {
    if ((this._Weight != value))
    {
    this.OnWeightChanging(value);
    this.SendPropertyChanging();
    this._Weight = value;
    this.SendPropertyChanged("Weight");
    this.OnWeightChanged();
    }
    }
    }

    [Column(Storage="_DaysToManufacture", DbType="Int NOT NULL")]
    public int DaysToManufacture
    {
    get
    {
    return this._DaysToManufacture;
    }
    set
    {
    if ((this._DaysToManufacture != value))
    {
    this.OnDaysToManufactureChanging(value);
    this.SendPropertyChanging();
    this._DaysToManufacture = value;
    this.SendPropertyChanged("DaysToManufacture");
    this.OnDaysToManufactureChanged();
    }
    }
    }

    [Column(Storage="_ProductLine", DbType="NChar(2)")]
    public string ProductLine
    {
    get
    {
    return this._ProductLine;
    }
    set
    {
    if ((this._ProductLine != value))
    {
    this.OnProductLineChanging(value);
    this.SendPropertyChanging();
    this._ProductLine = value;
    this.SendPropertyChanged("ProductLine");
    this.OnProductLineChanged();
    }
    }
    }

    [Column(Storage="_Class", DbType="NChar(2)")]
    public string Class
    {
    get
    {
    return this._Class;
    }
    set
    {
    if ((this._Class != value))
    {
    this.OnClassChanging(value);
    this.SendPropertyChanging();
    this._Class = value;
    this.SendPropertyChanged("Class");
    this.OnClassChanged();
    }
    }
    }

    [Column(Storage="_Style", DbType="NChar(2)")]
    public string Style
    {
    get
    {
    return this._Style;
    }
    set
    {
    if ((this._Style != value))
    {
    this.OnStyleChanging(value);
    this.SendPropertyChanging();
    this._Style = value;
    this.SendPropertyChanged("Style");
    this.OnStyleChanged();
    }
    }
    }

    [Column(Storage="_ProductSubcategoryID", DbType="Int")]
    public System.Nullable<int> ProductSubcategoryID
    {
    get
    {
    return this._ProductSubcategoryID;
    }
    set
    {
    if ((this._ProductSubcategoryID != value))
    {
    if (this._Production_ProductSubcategory.HasLoadedOrAssignedValue)
    {
    throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    }
    this.OnProductSubcategoryIDChanging(value);
    this.SendPropertyChanging();
    this._ProductSubcategoryID = value;
    this.SendPropertyChanged("ProductSubcategoryID");
    this.OnProductSubcategoryIDChanged();
    }
    }
    }

    [Column(Storage="_SellStartDate", DbType="DateTime NOT NULL")]
    public System.DateTime SellStartDate
    {
    get
    {
    return this._SellStartDate;
    }
    set
    {
    if ((this._SellStartDate != value))
    {
    this.OnSellStartDateChanging(value);
    this.SendPropertyChanging();
    this._SellStartDate = value;
    this.SendPropertyChanged("SellStartDate");
    this.OnSellStartDateChanged();
    }
    }
    }

    [Column(Storage="_SellEndDate", DbType="DateTime")]
    public System.Nullable<System.DateTime> SellEndDate
    {
    get
    {
    return this._SellEndDate;
    }
    set
    {
    if ((this._SellEndDate != value))
    {
    this.OnSellEndDateChanging(value);
    this.SendPropertyChanging();
    this._SellEndDate = value;
    this.SendPropertyChanged("SellEndDate");
    this.OnSellEndDateChanged();
    }
    }
    }

    [Column(Storage="_DiscontinuedDate", DbType="DateTime")]
    public System.Nullable<System.DateTime> DiscontinuedDate
    {
    get
    {
    return this._DiscontinuedDate;
    }
    set
    {
    if ((this._DiscontinuedDate != value))
    {
    this.OnDiscontinuedDateChanging(value);
    this.SendPropertyChanging();
    this._DiscontinuedDate = value;
    this.SendPropertyChanged("DiscontinuedDate");
    this.OnDiscontinuedDateChanged();
    }
    }
    }

    [Column(Name="rowguid", Storage="_Rowguid", DbType="UniqueIdentifier NOT NULL")]
    public System.Guid Rowguid
    {
    get
    {
    return this._Rowguid;
    }
    set
    {
    if ((this._Rowguid != value))
    {
    this.OnRowguidChanging(value);
    this.SendPropertyChanging();
    this._Rowguid = value;
    this.SendPropertyChanged("Rowguid");
    this.OnRowguidChanged();
    }
    }
    }

    [Column(Storage="_ModifiedDate", DbType="DateTime NOT NULL")]
    public System.DateTime ModifiedDate
    {
    get
    {
    return this._ModifiedDate;
    }
    set
    {
    if ((this._ModifiedDate != value))
    {
    this.OnModifiedDateChanging(value);
    this.SendPropertyChanging();
    this._ModifiedDate = value;
    this.SendPropertyChanged("ModifiedDate");
    this.OnModifiedDateChanged();
    }
    }
    }

    [Association(Name="FK_Product_ProductSubcategory_ProductSubcategoryID", Storage="_Production_ProductSubcategory", ThisKey="ProductSubcategoryID", IsForeignKey=true)]
    public Production_ProductSubcategory Production_ProductSubcategory
    {
    get
    {
    return this._Production_ProductSubcategory.Entity;
    }
    set
    {
    Production_ProductSubcategory previousValue = this._Production_ProductSubcategory.Entity;
    if (((previousValue != value)
    || (this._Production_ProductSubcategory.HasLoadedOrAssignedValue == false)))
    {
    this.SendPropertyChanging();
    if ((previousValue != null))
    {
    this._Production_ProductSubcategory.Entity = null;
    previousValue.Production_Product.Remove(this);
    }
    this._Production_ProductSubcategory.Entity = value;
    if ((value != null))
    {
    value.Production_Product.Add(this);
    this._ProductSubcategoryID = value.ProductSubcategoryID;
    }
    else
    {
    this._ProductSubcategoryID = default(Nullable<int>);
    }
    this.SendPropertyChanged("Production_ProductSubcategory");
    }
    }
    }

    public event PropertyChangingEventHandler PropertyChanging;

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void SendPropertyChanging()
    {
    if ((this.PropertyChanging != null))
    {
    this.PropertyChanging(this, emptyChangingEventArgs);
    }
    }

    protected virtual void SendPropertyChanged(String propertyName)
    {
    if ((this.PropertyChanged != null))
    {
    this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
    }
    }

    [Table(Name="Production.ProductSubcategory")]
    public partial class Production_ProductSubcategory : INotifyPropertyChanging, INotifyPropertyChanged
    {

    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

    private int _ProductSubcategoryID;

    private string _Name;

    private System.Guid _Rowguid;

    private System.DateTime _ModifiedDate;

    private EntitySet<Production_Product> _Production_Product;

    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnProductSubcategoryIDChanging(int value);
    partial void OnProductSubcategoryIDChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnRowguidChanging(System.Guid value);
    partial void OnRowguidChanged();
    partial void OnModifiedDateChanging(System.DateTime value);
    partial void OnModifiedDateChanged();
    #endregion

    public Production_ProductSubcategory()
    {
    this._Production_Product = new EntitySet<Production_Product>(new Action<Production_Product>(this.attach_Production_Product), new Action<Production_Product>(this.detach_Production_Product));
    OnCreated();
    }

    [Column(Storage="_ProductSubcategoryID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    public int ProductSubcategoryID
    {
    get
    {
    return this._ProductSubcategoryID;
    }
    set
    {
    if ((this._ProductSubcategoryID != value))
    {
    this.OnProductSubcategoryIDChanging(value);
    this.SendPropertyChanging();
    this._ProductSubcategoryID = value;
    this.SendPropertyChanged("ProductSubcategoryID");
    this.OnProductSubcategoryIDChanged();
    }
    }
    }

    [Column(Storage="_Name", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
    public string Name
    {
    get
    {
    return this._Name;
    }
    set
    {
    if ((this._Name != value))
    {
    this.OnNameChanging(value);
    this.SendPropertyChanging();
    this._Name = value;
    this.SendPropertyChanged("Name");
    this.OnNameChanged();
    }
    }
    }

    [Column(Name="rowguid", Storage="_Rowguid", DbType="UniqueIdentifier NOT NULL")]
    public System.Guid Rowguid
    {
    get
    {
    return this._Rowguid;
    }
    set
    {
    if ((this._Rowguid != value))
    {
    this.OnRowguidChanging(value);
    this.SendPropertyChanging();
    this._Rowguid = value;
    this.SendPropertyChanged("Rowguid");
    this.OnRowguidChanged();
    }
    }
    }

    [Column(Storage="_ModifiedDate", DbType="DateTime NOT NULL")]
    public System.DateTime ModifiedDate
    {
    get
    {
    return this._ModifiedDate;
    }
    set
    {
    if ((this._ModifiedDate != value))
    {
    this.OnModifiedDateChanging(value);
    this.SendPropertyChanging();
    this._ModifiedDate = value;
    this.SendPropertyChanged("ModifiedDate");
    this.OnModifiedDateChanged();
    }
    }
    }

    [Association(Name="FK_Product_ProductSubcategory_ProductSubcategoryID", Storage="_Production_Product", OtherKey="ProductSubcategoryID", DeleteRule="NO ACTION")]
    public EntitySet<Production_Product> Production_Product
    {
    get
    {
    return this._Production_Product;
    }
    set
    {
    this._Production_Product.Assign(value);
    }
    }

    public event PropertyChangingEventHandler PropertyChanging;

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void SendPropertyChanging()
    {
    if ((this.PropertyChanging != null))
    {
    this.PropertyChanging(this, emptyChangingEventArgs);
    }
    }

    protected virtual void SendPropertyChanged(String propertyName)
    {
    if ((this.PropertyChanged != null))
    {
    this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
    }

    private void attach_Production_Product(Production_Product entity)
    {
    this.SendPropertyChanging();
    entity.Production_ProductSubcategory = this;
    }

    private void detach_Production_Product(Production_Product entity)
    {
    this.SendPropertyChanging();
    entity.Production_ProductSubcategory = null;
    }
    }
    #pragma warning restore 1591


    Wednesday, September 3, 2008 11:05 PM
  • Can you turn on logging on your data context and see what SQL it is trying to run?

    Also, what version of SQL Server are you using?

    [)amie
    Thursday, September 4, 2008 3:46 PM
    Moderator