• 提供程序未返回 ProviderManifestToken 字符串 解决方案


    先上连接字符串:

    <connectionStrings>
    <add name="MusicStore" connectionString="data source=.;Initial Catalog=MusicStore;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
    </connectionStrings>

    Entity上下文类:

      public class MusicStoreEntities : DbContext
        {
            private readonly static string CONNECTION_STRING = "name=MusicStore";
    
            public DbSet<Album> Albums { get; set; }
            public DbSet<Genre> Genres { get; set; }
    
            public MusicStoreEntities()
                : base(CONNECTION_STRING)//不写这个  默认的就是SchoolContext
            {
    
            }
    
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//移除复数表名的契约
    
                modelBuilder.Conventions.Remove<IncludeMetadataConvention>();//防止黑幕交易 要不然每次都要访问 EdmMetadata这个表
    
    
    
    
                /*
                 
                 可以删除的公约有:
    Namespace:System.Data.Entity.ModelConfiguration.Conventions.Edm
    • AssociationInverseDiscoveryConvention 
    寻找导航上互相引用的类的属性,并将它们配置为逆属性的相同的关系。
    • ComplexTypeDiscoveryConvention 
    寻找有没有主键的类型,并将它们配置为复杂类型。
    • DeclaredPropertyOrderingConvention 
    确保每个实体的主要关键属性优先于其他属性。
    • ForeignKeyAssociationMultiplicityConvention 
    配置是必需的还是可选的关系基于为空性外键属性,如果包含在类定义中。
    • IdKeyDiscoveryConvention 
    查找名为 Id 或 <TypeName> Id 的属性,并将他们配置作为主键。
    • NavigationPropertyNameForeignKeyDiscoveryConvention 
    使用外键关系,使用 <NavigationProperty> <PrimaryKeyProperty> 模式作为属性的外观。
    • OneToManyCascadeDeleteConvention 
    交换机上层叠删除,所需的关系。
    • OneToOneConstraintIntroductionConvention 
    将配置为一个: 一个关系的外键的主键。
    • PluralizingEntitySetNameConvention 
    配置为多元化的类型名称的实体数据模型中的实体集的名称。
    • PrimaryKeyNameForeignKeyDiscoveryConvention 
    使用外键关系,使用 <PrimaryKeyProperty> 模式作为属性的外观。
    • PropertyMaxLengthConvention 
    配置所有的字符串和字节 [] 属性,默认情况下具有最大长度。
    • StoreGeneratedIdentityKeyConvention 
    配置默认情况下将标识所有整数的主键。
    • TypeNameForeignKeyDiscoveryConvention 
    使用外键关系,使用 <PrincipalTypeName> <PrimaryKeyProperty> 模式作为属性的外观。
    
                 
                 */
    
            }
    
        }
  • 相关阅读:
    正则表达式
    Newtonsoft.Json
    MVC之参数验证(三)
    MVC之参数验证(二)
    MVC之参数验证(一)
    MVC之模型绑定
    导致存储过程重新编译的原因
    IFormattable,ICustomFormatter, IFormatProvider接口
    oracle将id串转换为名字串
    oracle查看表空间大小及使用情况
  • 原文地址:https://www.cnblogs.com/shuoshuo/p/2773301.html
Copyright © 2020-2023  润新知