Problem refreshing tables in the LINQ to SQL designer

后端 未结 9 1403
野趣味
野趣味 2021-02-08 12:54

I have been using LINQ to SQL for a while, and there is one thing that has always bothered me. Whenever I modify the schema of a table, in order to refresh it in the designer, I

9条回答
  •  清歌不尽
    2021-02-08 13:17

    I personally detest using the designer, and I've had various issues with it whenever I've dared to use it.

    I mostly use LINQ for very simple CRUD (no linked entities or anything), and if that's the case with you, it might be worth straying from the designer crutch. Especially since defining LINQ-to-SQL entities is as easy as this:

    [Table("dbo.my_table")]
    public class MyTable
    {
    [Column("id", AutoSync = AutoSync.OnInsert, IsDbGenerated = true, IsPrimaryKey = true)]
    public Int32 Id { get; set; }
    
    [Column("name", DbType="NVarChar(50) NOT NULL")]
    public String Name { get; set; }
    }
    

    This way, all your entities have their own files, which makes finding them much easier, though you'll still have to add/update the properties manually.

    Of course, if you'd refactor 100+ tables, that might not be an option ;)

提交回复
热议问题