Summary of problems encountered by CRUD

Problems encountered by CRUD

(1)
When writing a custom class, id
must be used because it inherits a base class. If
int is used, there will be a problem that the implicit type cannot be converted.
(2)
Entity-storage-Dto should be named to achieve one-to-one correspondence
(3)
When implementing CRUD, you should 1.
Define the storage interface according to the operations to be done on the data.
2. Inherit EfCoreRepository . 3. Make the corresponding data context
in the generic parameters. build achievement commented out

//options.ConventionalControllers.Create(typeof(BookStoreApplicationModule).Assembly);

Supplement: Later, it was found that there was no such code at all. Looking back at the official document, there is a sentence that can be changed in

[RemoteService(IsEnabled = false)]

You can disable the automatic generation of api

Subsequent problems encountered
(1) 500 errors after execute in swagger First open the exception setting of vs and report an error when running, tick
and then find the error that this table cannot be found in the cmd console, and then find the first place from DbContext The Dbset table name must be consistent with the table name or an error will occur

  builder.Entity<Book>(b =>
        {
    
    
            b.ToTable(CloudConsts.DbTablePrefix + "Book",//这也得和表名一致
                CloudConsts.DbSchema);
            b.ConfigureByConvention();
            b.Property(b=>b.Name)
            .IsRequired()
            .HasMaxLength(128);
        });

Guess you like

Origin blog.csdn.net/weixin_45139296/article/details/131171546