Advertisement
Guest User

Migration

a guest
Dec 19th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 KB | None | 0 0
  1. Entidade:
  2. --
  3. using System.ComponentModel;
  4. using System.ComponentModel.DataAnnotations;
  5.  
  6. namespace Pharm.Dominio.Entidades
  7. {
  8.     public class Produtos
  9.     {
  10.         public int Id { get; set; }
  11.  
  12.         [Required(ErrorMessage = "É necessário preencher o código de barras")]
  13.         [DisplayName("Código de barras")]
  14.         public int codigoBarras { get; set; }
  15.         public string nome { get; set; }
  16.         public string descricao { get; set; }
  17.         public decimal precoMinimo { get; set; }
  18.         public decimal precoMaximo { get; set; }
  19.     }
  20. }
  21.  
  22.  
  23.  
  24. ----------------------------------
  25. Contexto:
  26.  
  27. using System.Data.Entity;
  28. using Pharm.Dominio.Entidades;
  29. using System.Data.Entity.ModelConfiguration.Conventions;
  30.  
  31. namespace Pharm.Dominio.Repositorio
  32. {
  33.     public class Contexto : DbContext
  34.     {
  35.         public DbSet<Produtos> Produtos { get; set; }
  36.  
  37.         protected override void OnModelCreating(DbModelBuilder modelBuider)
  38.         {
  39.             modelBuider.Conventions.Remove<PluralizingTableNameConvention>();
  40.         }
  41.     }
  42. }
  43.  
  44.  
  45. --------------------------------------
  46. App.config
  47.  
  48. <?xml version="1.0" encoding="utf-8"?>
  49. <configuration>
  50.   <connectionStrings>
  51.     <add name="Contexto" connectionString="Data Source=(local);Initial Catalog=Pharm;User ID=sa;Password=****" providerName="System.Data.SqlClient" />
  52.   </connectionStrings>
  53.   <configSections>
  54.     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  55.   </configSections>
  56.   <entityFramework>
  57.     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  58.       <parameters>
  59.         <parameter value="mssqllocaldb" />
  60.       </parameters>
  61.     </defaultConnectionFactory>
  62.     <providers>
  63.       <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  64.     </providers>
  65.   </entityFramework>
  66.   <runtime>
  67.     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  68.       <dependentAssembly>
  69.         <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
  70.         <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  71.       </dependentAssembly>
  72.     </assemblyBinding>
  73.   </runtime>
  74. </configuration>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement